Repository navigation
Studio: never follow a symlink when linking a file into a tool workspace - #13513
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix from the latest security scan. Nothing changes for normal uploads, attachments or tool output.
Problem. Studio writes files into a chat's tool workspace (uploads, attachment copies, spilled tool output, and files a prune puts back) by writing a temp file in that directory and then
os.link-ing it to its final name.os.linkfollows a symlink at its source by default. A tool running in the same workspace (for example code a prompt-injected model runs in the sandbox, or a managed account's own tool) can swap the in-flight temp name for a symlink to a host file while the bytes are being written. The backend then hard-links that host file into the sandbox, where the tool can read it. One target is Studio'sauth.db, which holds password hashes and JWT secrets.Reproduced on main: the uploaded name ends up with the same inode and contents as the host file.
Change (
core/inference/tools.py). The sixos.linkcalls that install into a tool-writable directory passfollow_symlinks=False, where the platform supports it:_write_spill_file(both branches)_install_attachment_copy(both branches)_install_upload_restore_pruned_path, which can be putting back a symlink the tool made; restoring the link itself is also the correct restore.A swapped temp name now ends up as a symlink. The sandbox cannot follow it to a host path, and the file listing and download already reject non-regular entries. On Windows
os.linktakes no such flag and hard links never follow a symlink source, so nothing changes there.Tests (
tests/test_sandbox_upload_link_race.py, new):tests/test_tool_result_fits_window.pyfail identically on main.