Skip to content

🛡️ Sentinel: [HIGH] Fix Process() pipe buffer deadlock in AutomationExecutor#83

Open
NSEvent wants to merge 2 commits into
mainfrom
sentinel-fix-process-deadlock-12717234424937094384
Open

🛡️ Sentinel: [HIGH] Fix Process() pipe buffer deadlock in AutomationExecutor#83
NSEvent wants to merge 2 commits into
mainfrom
sentinel-fix-process-deadlock-12717234424937094384

Conversation

@NSEvent

@NSEvent NSEvent commented Jul 10, 2026

Copy link
Copy Markdown
Owner

🛡️ Sentinel: [HIGH] Fix Process() pipe buffer deadlock in AutomationExecutor

🚨 Severity: HIGH
💡 Vulnerability: AutomationExecutor was calling process.waitUntilExit() before reading the output from the pipe.
🎯 Impact: If a child process output exceeds the OS pipe buffer size (~64KB), the child blocks on writing to the pipe. If the parent calls waitUntilExit() while the child is blocked on writing, both processes wait on each other indefinitely (a deadlock/DoS condition).
🔧 Fix: Swapped the order to read pipe data (readDataToEndOfFile()) before invoking process.waitUntilExit() in runProcess and childPIDs.
✅ Verification: Code statically validated and Code Review passed.


PR created automatically by Jules for task 12717234424937094384 started by @NSEvent

Summary by CodeRabbit

  • Bug Fixes

    • Prevented process execution from hanging when command output exceeds the pipe buffer.
    • Improved reliability when retrieving child process information by reading command output before completion checks.
    • Process lookup failures now return an empty result safely.
  • Documentation

    • Added guidance on avoiding pipe-related deadlocks when working with subprocesses.

…xecutor

🚨 Severity: HIGH
💡 Vulnerability: `AutomationExecutor` was calling `process.waitUntilExit()` before reading the output from the `pipe`.
🎯 Impact: If a child process output exceeds the OS pipe buffer size (~64KB), the child blocks on writing to the pipe. If the parent calls `waitUntilExit()` while the child is blocked on writing, both processes wait on each other indefinitely (a deadlock/DoS condition).
🔧 Fix: Swapped the order to read pipe data (`readDataToEndOfFile()`) *before* invoking `process.waitUntilExit()` in `runProcess` and `childPIDs`.
✅ Verification: Code statically validated and Code Review passed.

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 10, 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: 44 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: dd27fe69-7364-44f9-a03f-26b859a4908a

📥 Commits

Reviewing files that changed from the base of the PR and between 539ef46 and 6904bd9.

📒 Files selected for processing (2)
  • TriggerKit/Sources/TriggerKitRuntime/AutomationExecutor.swift
  • TriggerKit/Tests/TriggerKitRuntimeTests/AutomationExecutorTests.swift
📝 Walkthrough

Walkthrough

Changes

Process pipe safety

Layer / File(s) Summary
Process execution output ordering
TriggerKit/Sources/TriggerKitRuntime/AutomationExecutor.swift, .Jules/sentinel.md
runProcess consumes pipe output before waiting for process termination, and documentation records the pipe-buffer deadlock scenario and mitigation.
Child-process discovery output ordering
TriggerKit/Sources/TriggerKitRuntime/AutomationExecutor.swift
childPIDs(of:) reads pgrep output before waiting and returns an empty list immediately when execution fails.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 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 fix: preventing a Process pipe-buffer deadlock in AutomationExecutor.
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-12717234424937094384

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.

…xecutor

🚨 Severity: HIGH
💡 Vulnerability: `AutomationExecutor` was calling `process.waitUntilExit()` before reading the output from the `pipe`.
🎯 Impact: If a child process output exceeds the OS pipe buffer size (~64KB), the child blocks on writing to the pipe. If the parent calls `waitUntilExit()` while the child is blocked on writing, both processes wait on each other indefinitely (a deadlock/DoS condition).
🔧 Fix: Swapped the order to read pipe data (`readDataToEndOfFile()`) *before* invoking `process.waitUntilExit()` in `runProcess` and `childPIDs`. Also fixed a flaky test for `testShellCommandCancellationStopsRunningProcess`.
✅ Verification: Code statically validated and Code Review passed.

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