Skip to content

πŸ›‘οΈ Sentinel: Fix pipe deadlock DoS in process execution - #94

Open
NSEvent wants to merge 1 commit into
mainfrom
sentinel-dos-fix-365513411330066729
Open

πŸ›‘οΈ Sentinel: Fix pipe deadlock DoS in process execution#94
NSEvent wants to merge 1 commit into
mainfrom
sentinel-dos-fix-365513411330066729

Conversation

@NSEvent

@NSEvent NSEvent commented Jul 18, 2026

Copy link
Copy Markdown
Owner

🚨 Severity: MEDIUM
πŸ’‘ Vulnerability: When executing shell commands via Foundation.Process, the app was waiting for the child process to exit before reading its output pipe. If the child process output exceeded the OS pipe buffer size (~64KB), the child would block waiting to write, and the parent would block waiting for the child to exit.
🎯 Impact: This could result in a permanent deadlock and Denial of Service (DoS).
πŸ”§ Fix: Swapped the order to read the pipe buffer readDataToEndOfFile() before calling process.waitUntilExit().
βœ… Verification: Tested statically, verified syntax validity across modified swift files.


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

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of external processes to ensure output is captured reliably after process completion.
    • Improved process discovery and status checks for more dependable automation behavior.
  • Tests

    • Updated integration test process handling to improve consistency when locating and validating required components.

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 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

πŸ“ Walkthrough

Walkthrough

The changes reorder stdout and stderr pipe reads relative to waitUntilExit() in runtime process helpers and update the live integration test’s binary path resolution ordering.

Changes

Process pipe ordering

Layer / File(s) Summary
Runtime process helper ordering
TriggerKit/Sources/TriggerKitRuntime/AutomationExecutor.swift
runProcess and childPIDs(of:) now reorder pipe output reads relative to process termination waits.
Integration binary resolution
XboxControllerMapper/XboxControllerMapperTests/OBSWebSocketLiveIntegrationTests.swift
resolveBinaryPath() reads which output before evaluating its termination status.

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

Possibly related PRs

πŸš₯ 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 matches the main change: fixing a pipe deadlock DoS in process execution.
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 docstrings
  • Create stacked PR
  • Commit on current branch
πŸ§ͺ Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sentinel-dos-fix-365513411330066729

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.

Actionable comments posted: 1

πŸ€– 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.

Inline comments:
In
`@XboxControllerMapper/XboxControllerMapperTests/OBSWebSocketLiveIntegrationTests.swift`:
- Around line 169-172: Update the process-launch flow around which.run() to
catch its failure and immediately throw XCTSkip or return before reading from
outPipe. Only call readDataToEndOfFile() and waitUntilExit() after which.run()
succeeds, preserving the existing terminationStatus handling for launched
processes.
πŸͺ„ Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
βš™οΈ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5e69fe41-6f26-4e42-8427-635858c920da

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between ae38cc3 and 8b70246.

πŸ“’ Files selected for processing (2)
  • TriggerKit/Sources/TriggerKitRuntime/AutomationExecutor.swift
  • XboxControllerMapper/XboxControllerMapperTests/OBSWebSocketLiveIntegrationTests.swift

Comment on lines 169 to 172
try? which.run()
let data = outPipe.fileHandleForReading.readDataToEndOfFile()
which.waitUntilExit()
if which.terminationStatus == 0 {

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.

🩺 Stability & Availability | 🟠 Major | ⚑ Quick win

🧩 Analysis chain

🏁 Script executed:

sed -n '140,190p' XboxControllerMapper/XboxControllerMapperTests/OBSWebSocketLiveIntegrationTests.swift

Repository: NSEvent/xbox-controller-mapper

Length of output: 1989


Handle which.run() failures before reading the pipe. try? which.run() can leave the process unlaunched, and readDataToEndOfFile() will block waiting for EOF that never comes. Throw XCTSkip (or exit early) as soon as run() fails.

πŸ€– 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
`@XboxControllerMapper/XboxControllerMapperTests/OBSWebSocketLiveIntegrationTests.swift`
around lines 169 - 172, Update the process-launch flow around which.run() to
catch its failure and immediately throw XCTSkip or return before reading from
outPipe. Only call readDataToEndOfFile() and waitUntilExit() after which.run()
succeeds, preserving the existing terminationStatus handling for launched
processes.

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