🛡️ Sentinel: [CRITICAL/HIGH] Fix Foundation.Process pipe deadlock vulnerability#78
🛡️ Sentinel: [CRITICAL/HIGH] Fix Foundation.Process pipe deadlock vulnerability#78NSEvent wants to merge 3 commits into
Conversation
Co-authored-by: NSEvent <44446865+NSEvent@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning Review limit reached
Next review available in: 13 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis change fixes a potential pipe deadlock in ChangesProcess Pipe Deadlock Fix
Estimated code review effort: 1 (Trivial) | ~5 minutes Sequence Diagram(s)sequenceDiagram
participant AutomationExecutor
participant ChildProcess
participant Pipe
AutomationExecutor->>ChildProcess: launch process
AutomationExecutor->>Pipe: readDataToEndOfFile
Pipe-->>AutomationExecutor: output data
AutomationExecutor->>ChildProcess: waitUntilExit
ChildProcess-->>AutomationExecutor: terminationStatus
Related Issues: None found Related PRs: None found Suggested labels: bug, security Suggested reviewers: None found Poem:
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.Jules/sentinel.md (1)
21-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winPrevention guidance omits the two-pipe caveat.
The note's prevention advice — read the pipe before
waitUntilExit()— is correct for the single combined pipe fixed inAutomationExecutor.runProcess, but is incomplete as general guidance. When stdout and stderr use separate pipes, sequentially draining one pipe to EOF before waiting can still deadlock if the child fills the other pipe's buffer while that read is blocking.XboxControllerMapper/.../ScriptEngine.swiftalready handles this correctly by draining both pipes concurrently (viaDispatchGroup) before callingwaitUntilExit(). Consider extending the "Prevention" bullet to call out the multi-pipe case so future fixes based on this note don't miss it.📝 Suggested guidance addition
**Prevention:** Always read data from the pipe (e.g., `pipe.fileHandleForReading.readDataToEndOfFile()`) *before* calling `process.waitUntilExit()` to ensure the pipe is drained as the child writes. +If stdout and stderr use separate pipes, drain both concurrently (e.g., via `DispatchGroup` or separate threads) before calling `waitUntilExit()` — sequentially draining only one pipe can still deadlock on the other.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.Jules/sentinel.md around lines 21 - 24, The Prevention note in sentinel.md is incomplete for the multi-pipe case: it only describes draining one pipe before waitUntilExit(). Update the guidance to distinguish single combined output pipes from separate stdout/stderr pipes, and explicitly state that when both exist they must be drained concurrently before calling waitUntilExit(). Use AutomationExecutor.runProcess and ScriptEngine as the reference examples so future fixes don’t reintroduce the deadlock.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.Jules/sentinel.md:
- Around line 21-24: The Prevention note in sentinel.md is incomplete for the
multi-pipe case: it only describes draining one pipe before waitUntilExit().
Update the guidance to distinguish single combined output pipes from separate
stdout/stderr pipes, and explicitly state that when both exist they must be
drained concurrently before calling waitUntilExit(). Use
AutomationExecutor.runProcess and ScriptEngine as the reference examples so
future fixes don’t reintroduce the deadlock.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 14af5da5-e5a7-496f-9c8b-8e20aa81043f
📒 Files selected for processing (2)
.Jules/sentinel.mdTriggerKit/Sources/TriggerKitRuntime/AutomationExecutor.swift
Co-authored-by: NSEvent <44446865+NSEvent@users.noreply.github.com>
Co-authored-by: NSEvent <44446865+NSEvent@users.noreply.github.com>
🛡️ Sentinel: [CRITICAL/HIGH] Fix Foundation.Process pipe deadlock vulnerability
🚨 Severity: HIGH
💡 Vulnerability: Execution frameworks using
Foundation.Processto run shell commands or scripts were vulnerable to a pipe deadlock and Denial of Service (DoS) if the child process output exceeded the OS pipe buffer (~64KB). The parent process would block onwaitUntilExit()while the child process blocked waiting for the parent to drain the pipe.🎯 Impact: An attacker or untrusted automation configuration could cause the application to hang/deadlock by outputting large amounts of data, leading to resource exhaustion and denial of service.
🔧 Fix: Moved
pipe.fileHandleForReading.readDataToEndOfFile()to beforeprocess.waitUntilExit()inAutomationExecutor.swiftto ensure the pipe is drained properly.✅ Verification: Code visually inspected and structurally verified. Code review passed successfully.
PR created automatically by Jules for task 13440826097936387111 started by @NSEvent
Summary by CodeRabbit
Bug Fixes
Documentation