Skip to content

Run fs helper through Windows sandbox wrapper#28359

Merged
iceweasel-oai merged 6 commits into
mainfrom
codex/windows-fs-helper-wrapper-stack
Jun 17, 2026
Merged

Run fs helper through Windows sandbox wrapper#28359
iceweasel-oai merged 6 commits into
mainfrom
codex/windows-fs-helper-wrapper-stack

Conversation

@iceweasel-oai

@iceweasel-oai iceweasel-oai commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Why

This is the final PR in the Windows fs-helper sandbox stack and contains the actual bug fix.

The exec-server filesystem helper is a direct-spawn path: it asks SandboxManager for a SandboxExecRequest, then launches the returned argv itself. That works on macOS and Linux because the transformed argv is already a self-contained sandbox wrapper. On Windows, the transformed request carried WindowsRestrictedToken metadata, but the direct-spawn fs-helper runner still launched the helper argv directly.

That means Windows filesystem built-ins backed by the fs-helper could run with the parent Codex process permissions instead of the configured Windows sandbox. This PR makes the direct-spawn transform produce a self-contained Windows wrapper argv before fs-helper launches it.

What Changed

  • Added SandboxManager::transform_for_direct_spawn() for callers that launch the returned argv themselves.
  • Wrapped Windows restricted-token direct-spawn requests with codex.exe --run-as-windows-sandbox and then marked the outer request as unsandboxed, matching the macOS/Linux wrapper argv shape.
  • Updated exec-server/src/fs_sandbox.rs to use the direct-spawn transform for fs-helper launches.
  • Materialized the inner codex.exe --codex-run-as-fs-helper executable into .sandbox-bin so the sandboxed user can run it.
  • Carried runtime workspace roots through FileSystemSandboxContext as PathUri values so :workspace_roots policies resolve correctly without sending native client paths over exec-server JSON.
  • Preserved wrapper setup identity environment needed by Windows sandbox setup without changing the serialized inner helper environment.

Verification

  • just bazel-lock-update
  • just bazel-lock-check
  • just test -p codex-sandboxing transform_for_direct_spawn_windows
  • just test -p codex-exec-server fs_sandbox::tests
  • just fix -p codex-windows-sandbox -p codex-sandboxing -p codex-exec-server -p codex-core -p codex-file-system

Local note: just fmt completed Rust formatting, but this workstation still fails the non-Rust formatter phases because uv cannot open its cache and the local buildifier/dotslash path is missing.

@iceweasel-oai
iceweasel-oai requested a review from a team as a June 15, 2026 17:52

@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: 6f14dbd816

ℹ️ 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/file-system/src/lib.rs Outdated
@@ -53,6 +54,8 @@ pub struct FileSystemSandboxContext {
pub permissions: PermissionProfile,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub cwd: Option<PathUri>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub workspace_roots: Vec<AbsolutePathBuf>,

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 Avoid sending native roots over remote exec-server JSON

When the filesystem environment is remote on another OS, this new AbsolutePathBuf field serializes the client host's native paths while cwd and operation paths use PathUri specifically to avoid native conversion. A Windows client with workspaceRoots: ["C:\\repo"] talking to a Unix exec-server will fail deserializing the sandbox context before any sandboxed fs/* operation can run. Please carry these roots as URIs or populate them only after translating on the exec-server host.

Useful? React with 👍 / 👎.

Comment thread codex-rs/sandboxing/src/manager_tests.rs Outdated
@iceweasel-oai
iceweasel-oai force-pushed the codex/windows-fs-helper-wrapper-stack branch from 6f14dbd to e68bc1a Compare June 15, 2026 18:25
@iceweasel-oai
iceweasel-oai force-pushed the codex/windows-sandbox-wrapper-entrypoint branch from 36421a9 to a6155c2 Compare June 15, 2026 18:25
Comment thread codex-rs/windows-sandbox-rs/src/helper_materialization.rs
Comment thread codex-rs/exec-server/src/fs_sandbox.rs

@pakrym-oai pakrym-oai 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.

needs tests

@iceweasel-oai
iceweasel-oai force-pushed the codex/windows-sandbox-wrapper-entrypoint branch from a6155c2 to 60d8329 Compare June 15, 2026 20:27
Base automatically changed from codex/windows-sandbox-wrapper-entrypoint to main June 15, 2026 21:30
@iceweasel-oai
iceweasel-oai force-pushed the codex/windows-fs-helper-wrapper-stack branch from 6eb226d to 653ab5f Compare June 15, 2026 21:50
@iceweasel-oai
iceweasel-oai requested a review from pakrym-oai June 16, 2026 18:24
@iceweasel-oai
iceweasel-oai merged commit ef75171 into main Jun 17, 2026
45 of 47 checks passed
@iceweasel-oai
iceweasel-oai deleted the codex/windows-fs-helper-wrapper-stack branch June 17, 2026 17:00
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants