[LOW] Close duplex pipe ends when launch fails - #203
Open
OskarEichler wants to merge 1 commit into
Open
OskarEichler wants to merge 1 commit into
OskarEichler wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes both internally created duplex pipe ends when
Process.spawnraises, preventing each failed launch from leaking two descriptors in the parent.Security impact
LOW: when an application enables duplex mode and repeatedly attempts an attacker-influenced or unavailable executable, every failed launch retains two file descriptors until process exit. Repeated failures can exhaust the parent's descriptor limit and deny unrelated file, socket, and process operations.
The
ensureblock closes only the gem-owned pipe ends when no child PID was assigned. Successful launch behavior is unchanged.Reproduction
On 5.1.0, 50 failed duplex launches of a missing executable grow
/dev/fdby exactly 100 descriptors. The same bounded reproduction reports zero growth on this branch.Verification
ChildProcess::LaunchError.git diff --checkpasses.All Ruby-backed checks used rbenv.
Limitations
The descriptor count reproduction was run on macOS. Windows, JRuby, and TruffleRuby were not run locally.
Breaking changes
None. The patch only closes internal resources after a failed spawn.