-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Elevated Sandbox 3 #7809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elevated Sandbox 3 #7809
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ 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".
f8b4ff0 to
a2e9b51
Compare
|
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ 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".
| if ok == 0 { | ||
| return Err(anyhow::anyhow!("SetInformationJobObject failed")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close job handle when SetInformationJobObject fails
If SetInformationJobObject fails, the function returns early without closing the job handle and the caller later drops the error with .ok(), so the handle is leaked and the process runs without the intended kill-on-close guard. When the job setup fails (e.g., due to missing privileges), a subsequent crash or timeout can leave the child process orphaned because the job object never enforces kill-on-close.
Useful? React with 👍 / 👎.
| ); | ||
|
|
||
| let policy = parse_policy(&req.policy_json_or_preset).context("parse policy_json_or_preset")?; | ||
| let psid_cap: *mut c_void = unsafe { convert_string_sid_to_sid(&req.cap_sid).unwrap() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reject invalid capability SID instead of panicking
The runner converts the capability SID with convert_string_sid_to_sid(&req.cap_sid).unwrap(). If the request file contains an invalid SID string (corrupted or user-supplied), this panics before any logging or cleanup instead of returning a structured error, so the command runner will crash rather than reporting a bad request.
Useful? React with 👍 / 👎.
etraut-openai
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I spotted one potential problem that you should look into before merging.
| ) | ||
| }; | ||
| let (proc_info, _si) = match spawn_result { | ||
| Ok(v) => v, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're closing these handles only in the error case. I'm not 100%, but I think we probably want to close them in the success case as well. I think these handles are ref counted by the kernel, so when they're passed to CreateProcessAsUserW, the ref count will be incremented. Since we don't close them here, they will never be closed. You should confirm this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great catch! I'll fix this
| }; | ||
|
|
||
| // Optional job kill on close. | ||
| let h_job = unsafe { create_job_kill_on_close().ok() }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of a job object!
dedicated sandbox command runner exe.