Repository navigation
Filter Windows sandbox roots from SSH config dependencies - #18493
Merged
efrazer-oai merged 4 commits intoApr 19, 2026
Merged
Conversation
efrazer-oai
force-pushed
the
efrazer/windows-sandbox-block-profile-root
branch
from
April 18, 2026 18:42
ab952b1 to
d4f84ad
Compare
efrazer-oai
force-pushed
the
efrazer/windows-sandbox-ssh-dependency-roots-v2
branch
from
April 18, 2026 18:46
88228de to
6a15ba6
Compare
efrazer-oai
force-pushed
the
efrazer/windows-sandbox-block-profile-root
branch
from
April 18, 2026 18:58
d4f84ad to
2f71016
Compare
efrazer-oai
force-pushed
the
efrazer/windows-sandbox-ssh-dependency-roots-v2
branch
3 times, most recently
from
April 18, 2026 19:13
9d9d627 to
87dc7ab
Compare
efrazer-oai
added a commit
that referenced
this pull request
Apr 19, 2026
efrazer-oai
added a commit
that referenced
this pull request
Apr 19, 2026
efrazer-oai
marked this pull request as ready for review
April 19, 2026 16:20
xl-openai
approved these changes
Apr 19, 2026
efrazer-oai
force-pushed
the
efrazer/windows-sandbox-ssh-dependency-roots-v2
branch
from
April 19, 2026 19:37
96d1d9f to
6a8fe3b
Compare
efrazer-oai
added a commit
that referenced
this pull request
Apr 19, 2026
## Stack 1. This PR: expand and filter `USERPROFILE` roots. 2. Follow-up: #18493 filters SSH config dependency roots on top of this base. ## Bug On Windows, Codex can grant the sandbox ACL access to the whole user profile directory. That means the sandbox ACL can be applied under paths like: ```text C:\Users\me\.ssh C:\Users\me\.tsh ``` This breaks SSH. Windows OpenSSH checks permissions on SSH config and key material. If Codex adds a sandbox group ACL to those files, OpenSSH can reject the config or keys. The bad interaction is: 1. Codex asks the Windows sandbox to grant access to `USERPROFILE`. 2. The sandbox applies ACLs under that root. 3. SSH-owned files get an extra ACL entry. 4. OpenSSH rejects those files because their permissions are no longer strict enough. ## Why this happens more now Codex now has more flows that naturally start in the user profile: - a new chat can start in the user directory - a project can be rooted in the user directory - a user can start the Codex CLI from the user directory Those are valid user actions. The bug is that `USERPROFILE` is too broad a sandbox root. ## Change This PR keeps the useful behavior of starting from the user profile without granting the profile root itself. The new flow is: 1. collect the normal read and write roots 2. if a root is exactly `USERPROFILE`, replace it with the direct children of `USERPROFILE` 3. remove `USERPROFILE` itself from the final root list 4. apply the existing user-profile read exclusions to both read and write roots 5. add `.tsh` and `.brev` to that exclusion list So this input: ```text C:\Users\me ``` becomes roots like: ```text C:\Users\me\Desktop C:\Users\me\Documents C:\Users\me\Downloads ``` and does not include: ```text C:\Users\me C:\Users\me\.ssh C:\Users\me\.tsh C:\Users\me\.brev ``` If `USERPROFILE` cannot be listed, expansion falls back to the profile root and the later filter removes it. That keeps the failure mode closed for this bug. ## Why this shape The sandbox still gets access to ordinary profile folders when the user starts from home. The sandbox no longer grants access to the profile root itself. All filtering happens after expansion, for both read and write roots. That gives us one simple rule: expand broad profile grants first, then remove roots the sandbox must not own. ## Tests - `just fmt` - `cargo test -p codex-windows-sandbox` - `just fix -p codex-windows-sandbox` - `git diff --check`
Base automatically changed from
efrazer/windows-sandbox-block-profile-root
to
main
April 19, 2026 20:59
efrazer-oai
force-pushed
the
efrazer/windows-sandbox-ssh-dependency-roots-v2
branch
from
April 19, 2026 21:02
6a8fe3b to
abd3f86
Compare
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Stack
USERPROFILE.Bug
The base PR removes the broadest bad grant:
USERPROFILEitself.That still leaves one important case. A user profile child can be SSH-owned even when its name is not one of our fixed exclusions.
For example:
After profile expansion, the sandbox might see these as normal profile children:
Those paths have another owner: OpenSSH and the tools that manage SSH identity and host-key state. Codex should not add sandbox ACLs to them.
OpenSSH describes this dependency tree in
ssh_config(5), and the client parser follows the same shape inreadconf.c:Includerecursively reads more config files and expands globsIdentityFileandCertificateFilename authentication filesUserKnownHostsFile,GlobalKnownHostsFile, andRevokedHostKeysname host-key filesControlPathandIdentityAgentcan name profile-owned sockets or control files~,%d, and${HOME}Change
This PR adds a small SSH config dependency scanner.
It starts at:
Then it returns concrete paths named by
Includeand by path-valued SSH config directives:For example:
returns paths like:
The setup code then maps those paths back to their top-level
USERPROFILEchild and filters matching sandbox roots out of both the writable and readable root lists.Why this shape
The parser reports what SSH config references. The sandbox setup code decides which
USERPROFILEroots are unsafe to grant.That keeps the policy simple:
If a path has two possible owners, the sandbox steps back. SSH keeps control of SSH config, keys, certificates, known-hosts files, sockets, and included config files.
Tests
cargo test -p codex-windows-sandbox --libjust bazel-lock-checkjust fix -p codex-windows-sandboxgit diff --check