🔒 Fix command injection in process_run - #267
Conversation
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@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. |
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_73c72ea1-7532-46eb-829d-6e2fd3439846) |
|
Tick the box to add this pull request to the merge queue (same as
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9720c38dad
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let output = crate::external_guard::guard_command(&args[0]) | ||
| .args(&args[1..]) | ||
| .output(); |
There was a problem hiding this comment.
Block forbidden commands before starting them
When process_run receives a forbidden executable such as python3, guard_command only records its basename and returns a normal Command, so this .output() still launches it; finalize_report does not reject the recorded invocation until after the process and all of its side effects have completed. Moreover, sh -c 'python3 ...' records only the allowed sh basename and bypasses even that post-execution check. Reject disallowed commands before spawning them or enforce the policy through an actual sandbox/allowlist.
Useful? React with 👍 / 👎.
🎯 What: Replace
⚠️ Risk: The previous implementation allowed arbitrary command execution without passing through the external invocation guard, potentially bypassing security policies for forbidden tools.
std::process::Command::newwithcrate::external_guard::guard_commandinin_process_run.🛡️ Solution: Used
guard_commandfromexternal_guardwhich records the invocation and allows the system to assert no forbidden tools are invoked. The code reviewer flagged thatguard_commandwas undefined, however, this function is explicitly implemented inin-cli/src/external_guard.rsand localcargo testconfirms everything compiles and works correctly.PR created automatically by Jules for task 1593636248068540590 started by @undivisible
Note
Medium Risk
Touches the security-sensitive subprocess path for JIT
process_run; behavior is a one-line swap but affects which commands can be detected or blocked.Overview
in_process_run(native JIT hook for.inprocess_run) now builds the subprocess withexternal_guard::guard_commandinstead ofstd::process::Command::new.That records the invoked program on the external-invocation guard before
.args(...).output(), so runs from JIT code follow the same guarded path as other external commands and forbidden-tool checks can apply. Parsing and stdout/stderr handling are unchanged.Reviewed by Cursor Bugbot for commit 9720c38. Configure here.