Skip to content

windows-sandbox: remove SandboxPolicy runner plumbing#23813

Open
bolinfest wants to merge 1 commit into
mainfrom
pr23813
Open

windows-sandbox: remove SandboxPolicy runner plumbing#23813
bolinfest wants to merge 1 commit into
mainfrom
pr23813

Conversation

@bolinfest
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest commented May 21, 2026

Why

The Windows sandbox runner still carried the old SandboxPolicy compatibility path even though core now computes PermissionProfile. That meant Windows command-runner execution could only see the legacy projection, so profile-only filesystem rules such as deny globs were not part of the runner input.

What Changed

  • Removed the Windows-local SandboxPolicy parser/export and deleted windows-sandbox-rs/src/policy.rs.
  • Changed restricted-token capture/session setup, elevated setup, world-writable audit, read-root grant, and command-runner session APIs to accept PermissionProfile plus the profile cwd.
  • Bumped the elevated command-runner IPC protocol to version 2 because SpawnRequest now carries permission_profile / permission_profile_cwd instead of the legacy policy_json_or_preset / sandbox_policy_cwd fields.
  • Updated core exec, unified exec, debug-sandbox, TUI setup/grant flows, and app-server setup to pass the actual effective PermissionProfile.
  • Left regression coverage asserting the old IPC policy fields are absent and the runner serializes tagged PermissionProfile JSON.

Verification

  • cargo test -p codex-windows-sandbox
  • cargo test -p codex-core windows_sandbox
  • cargo test -p codex-app-server request_processors::windows_sandbox_processor
  • just fix -p codex-windows-sandbox -p codex-core -p codex-app-server -p codex-cli -p codex-tui
  • just fix -p codex-cli -p codex-tui
  • just fix -p codex-windows-sandbox -p codex-tui
  • rg "\\bSandboxPolicy\\b" codex-rs/windows-sandbox-rs returned no matches.

Note: cargo test -p codex-cli was attempted but did not reach crate tests because local disk filled while compiling dependencies (No space left on device). The targeted clippy pass compiled the affected CLI/TUI surfaces afterward.

@bolinfest bolinfest requested a review from a team as a code owner May 21, 2026 03:36
Copy link
Copy Markdown
Contributor

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

Reviewed commit: d41c5da300

ℹ️ 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 on lines +19 to +25
let Ok(permissions) =
codex_windows_sandbox::ResolvedWindowsSandboxPermissions::try_from_permission_profile_for_cwd(
&permission_profile,
cwd.as_path(),
)
else {
return Some((Vec::new(), 0, true));
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.

P2 Badge Do not treat unsupported profiles as scan failures

Returning Some((Vec::new(), 0, true)) on any try_from_permission_profile_for_cwd error causes a false "world-writable scan failed" warning for non-managed profiles (for example Full Access / PermissionProfile::Disabled). In that state there is no Windows sandbox policy to enforce, so this path should be a no-op rather than a failure prompt; otherwise users can get a misleading blocking warning when switching back to Agent mode from Full Access.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8445ece. Unsupported/non-managed profiles now return None from the synchronous warning-details path and the background scan exits without sending a failed-scan warning.

Comment thread codex-rs/windows-sandbox-rs/src/lib.rs Outdated
Comment on lines +582 to +585
let permissions = super::resolved_permissions::ResolvedWindowsSandboxPermissions::try_from_permission_profile_for_cwd(
permission_profile,
permission_profile_cwd,
)?;
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.

P2 Badge Skip preflight for unenforceable permission profiles

run_windows_sandbox_legacy_preflight now hard-fails on non-managed profiles before checking whether write-capability setup is needed. For unelevated setup flows that start from Full Access (PermissionProfile::Disabled) this turns a previously successful no-op preflight into an error, so windowsSandbox/setupStart can report failure even though no legacy ACL prep is required yet.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 8445ece. run_windows_sandbox_legacy_preflight now no-ops for profiles that cannot resolve to managed Windows sandbox permissions, and the setup refresh helpers match the same behavior. I added Windows-only regression tests for Disabled and External profiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant