Skip to content

Studio: never follow a symlink when linking a file into a tool workspace - #13513

Merged
danielhanchen merged 2 commits into
mainfrom
sec/s132-sandbox-link-nofollow
Oct 13, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
sec/s132-sandbox-link-nofollow

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

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.link follows 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's auth.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 six os.link calls that install into a tool-writable directory pass follow_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.link takes no such flag and hard links never follow a symlink source, so nothing changes there.

Tests (tests/test_sandbox_upload_link_race.py, new):

  • The upload's chunk iterator swaps the temp name for a symlink to a "secret" file mid-write. On main the upload becomes a hard link to it (same inode); with this PR it does not, and the secret keeps a link count of 1.
  • A normal upload is still a regular file with the uploaded bytes and leaves no temp file behind.
  • Related sandbox, upload, attachment, spill and prune suites: 7273 passed, 4 skipped. Two failures in tests/test_tool_result_fits_window.py fail identically on main.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T02:26:26.758936Z 7a5ff48 Manual 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 7a5ff48eb8

ℹ️ 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".

@mahiatlinux mahiatlinux self-assigned this Oct 13, 2026
@danielhanchen
danielhanchen merged commit 27ee3d3 into main Oct 13, 2026
@danielhanchen
danielhanchen deleted the sec/s132-sandbox-link-nofollow branch October 13, 2026 03:09
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.

2 participants