Skip to content

fix(windows-sandbox): allow deletion in writable roots#31138

Open
fcoury-oai wants to merge 3 commits into
mainfrom
codex/fix-windows-sandbox-delete-acl
Open

fix(windows-sandbox): allow deletion in writable roots#31138
fcoury-oai wants to merge 3 commits into
mainfrom
codex/fix-windows-sandbox-delete-acl

Conversation

@fcoury-oai

@fcoury-oai fcoury-oai commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Why

The legacy unelevated Windows sandbox allowed tools to create and update files in workspace-write roots, but it could not delete files that already existed there. This breaks operations such as apply_patch file deletion and replacement in the workspace, TEMP, and TMP.

The delete grant must also preserve deny-write carveouts. Granting FILE_DELETE_CHILD on a writable parent would let the sandbox remove protected children such as .git or an explicit read-only subpath even when those children have direct deny ACEs.

This addresses the delete-failure variant reported in #30009 and #30712. It does not claim to fix their separate split-root setup, elevated-helper, or proxy-related failure modes.

What Changed

  • Give writable-root capability ACEs inheritable DELETE rights without granting parent-level FILE_DELETE_CHILD, so descendants can be removed while protected children remain protected.
  • Replace stale write ACEs that still contain FILE_DELETE_CHILD, and make elevated setup detect and refresh that unsafe legacy state.
  • Keep read-only capability handling unchanged.
  • Add Windows regressions covering pre-existing files in the workspace, TEMP, and TMP, plus protected .git and outside-root controls.

The core ACL behavior is in acl.rs, stale-ACE detection is in setup_main/win.rs, and the end-to-end regression is in unified_exec/tests.rs.

How to Test

On Windows:

  1. Start Codex with the legacy unelevated Windows sandbox and a workspace-write permission profile.
  2. Seed pre-existing files in the workspace, TEMP, and TMP; also create a sibling file outside the writable roots and a protected .git directory.
  3. Delete the three files inside writable roots through a sandboxed command or apply_patch.
  4. Confirm the writable-root files are deleted, while the outside-root file and protected .git directory remain intact.

Targeted tests:

  • just test -p codex-windows-sandbox
  • Windows-only legacy_workspace_write_delete_is_limited_to_writable_roots
  • Windows-only write_root_refresh_replaces_stale_delete_child_grant

The final SHA passed all 31 required checks, including the Windows Bazel test matrix, in run 28886245161.

@PurpleDevX

PurpleDevX commented Jul 7, 2026

Copy link
Copy Markdown

It seems crazy that this is taking so long to be merged, considering how small the fix is, how big of a deal the issue is, and how long it's already been broken for. The amount of compute wasted by this bug alone at scale is not insignificant.

@fcoury-oai fcoury-oai marked this pull request as ready for review July 7, 2026 14:34

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0119f3bfc0

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

Comment thread codex-rs/windows-sandbox-rs/src/spawn_prep.rs
@fcoury-oai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0916a34301

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

Comment thread codex-rs/windows-sandbox-rs/src/bin/setup_main/win.rs Outdated
@fcoury-oai

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

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

Reviewed commit: 3f97310e63

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

@fcoury-oai fcoury-oai force-pushed the codex/fix-windows-sandbox-delete-acl branch from 3f97310 to 767540e Compare July 7, 2026 17:36
@fcoury-oai fcoury-oai changed the title fix(windows-sandbox): grant delete rights to writable roots fix(windows-sandbox): allow deletion in writable roots Jul 7, 2026
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