Prevent filesystem-root read denies in the Windows sandbox (#44327)

## Why

The elevated Windows sandbox requires effective `:root` read access and cannot safely enforce policies that deny reads at the filesystem root.

## What changed

- Validate root read access before elevated setup, service provisioning, and setup refresh, rejecting root-denying globs before expansion.
- Reject filesystem-root deny-read ACL targets after canonicalization and check the opened handle before applying an ACL, so aliases cannot bypass the root guard.
- Read and update deny ACLs through the same handle, and allow an existing deny ACE to be recognized when write access to the ACL is unavailable.

## Testing

Add regression coverage for default root denial, root-denying globs, allowed root reads with narrower deny rules, handle-based root detection, and reading existing deny ACEs without `WRITE_DAC`.

GitOrigin-RevId: b904e7cdbc09ee0147e1818c898b0382b5820c1b
This commit is contained in:
iceweasel-oai authored and copyberry committed 2026-09-09 22:50:03 +00:00
1 parent 0adfc1f2f2
commit f11d0dd012
9 files changed
+392 -30

No files matched your search

@@ -123,14 +123,17 @@ impl WindowsSandboxRequestProcessor {
let service_setup_request = setup_request.clone();
let service_setup_start = Instant::now();
tokio::task::spawn_blocking(move || -> anyhow::Result<()> {
if codex_windows_sandbox::ResolvedWindowsSandboxPermissions::try_from_permission_profile_for_workspace_roots(
let Ok(permissions) = codex_windows_sandbox::ResolvedWindowsSandboxPermissions::try_from_permission_profile_for_workspace_roots(
&service_setup_request.permission_profile,
&service_setup_request.workspace_roots,
).is_err() {
) else {
// The existing setup path can still succeed for completed
// provisioning without resolving the current profile.
return Ok(());
}
};
permissions.validate_elevated_filesystem_policy(
&service_setup_request.command_cwd,
)?;
// The shared setup path below handles helper fallback and
// refreshes workspace ACLs after provisioning.
codex_windows_sandbox::provision_windows_sandbox_via_service(