Skip to content

🛡️ Sentinel: [CRITICAL/HIGH] Fix Foundation.Process pipe deadlock vulnerability#78

Open
NSEvent wants to merge 3 commits into
mainfrom
sentinel/fix-process-deadlock-13440826097936387111
Open

🛡️ Sentinel: [CRITICAL/HIGH] Fix Foundation.Process pipe deadlock vulnerability#78
NSEvent wants to merge 3 commits into
mainfrom
sentinel/fix-process-deadlock-13440826097936387111

Conversation

@NSEvent

@NSEvent NSEvent commented Jul 7, 2026

Copy link
Copy Markdown
Owner

🛡️ Sentinel: [CRITICAL/HIGH] Fix Foundation.Process pipe deadlock vulnerability

🚨 Severity: HIGH
💡 Vulnerability: Execution frameworks using Foundation.Process to 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 on waitUntilExit() 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 before process.waitUntilExit() in AutomationExecutor.swift to 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

    • Prevents a potential hang when running processes by capturing output before waiting for completion.
    • Improves reliability for shell/script-based process execution and reduces the risk of deadlocks.
  • Documentation

    • Added guidance about the safe order for reading process output and waiting for exit.

Co-authored-by: NSEvent <44446865+NSEvent@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@NSEvent, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 13 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 184c8934-af1b-45d8-9bef-1146a4e0c4c4

📥 Commits

Reviewing files that changed from the base of the PR and between 2cd113e and 644ce07.

📒 Files selected for processing (3)
  • TriggerKit/Sources/TriggerKitRuntime/AutomationExecutor.swift
  • XboxControllerMapper/XboxControllerMapper/Services/Input/UniversalControlMouseRelay.swift
  • XboxControllerMapper/XboxControllerMapperTests/OBSWebSocketLiveIntegrationTests.swift
📝 Walkthrough

Walkthrough

This change fixes a potential pipe deadlock in AutomationExecutor.runProcess by reading pipe output before calling waitUntilExit(), instead of after. A corresponding documentation entry describing the deadlock vulnerability and prevention guidance was added to .Jules/sentinel.md.

Changes

Process Pipe Deadlock Fix

Layer / File(s) Summary
Reorder pipe drain before exit wait
TriggerKit/Sources/TriggerKitRuntime/AutomationExecutor.swift, .Jules/sentinel.md
runProcess now reads pipe output to end-of-file before calling waitUntilExit() to avoid deadlock; sentinel.md documents the vulnerability and prevention guidance.

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
Loading

Related Issues: None found

Related PRs: None found

Suggested labels: bug, security

Suggested reviewers: None found

Poem:

A pipe once held its breath so tight,
Waiting for exit, day and night.
Now we drain it first, then wait—
No deadlock left to seal our fate. 🐰💨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: fixing the Foundation.Process pipe deadlock vulnerability.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel/fix-process-deadlock-13440826097936387111

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
.Jules/sentinel.md (1)

21-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Prevention guidance omits the two-pipe caveat.

The note's prevention advice — read the pipe before waitUntilExit() — is correct for the single combined pipe fixed in AutomationExecutor.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.swift already handles this correctly by draining both pipes concurrently (via DispatchGroup) before calling waitUntilExit(). 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

📥 Commits

Reviewing files that changed from the base of the PR and between c431981 and 2cd113e.

📒 Files selected for processing (2)
  • .Jules/sentinel.md
  • TriggerKit/Sources/TriggerKitRuntime/AutomationExecutor.swift

google-labs-jules Bot and others added 2 commits July 7, 2026 09:18
Co-authored-by: NSEvent <44446865+NSEvent@users.noreply.github.com>
Co-authored-by: NSEvent <44446865+NSEvent@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant