mirror of
https://github.com/openai/codex.git
synced 2026-11-17 14:58:36 +00:00
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:
1 parent
0adfc1f2f2
commit
f11d0dd012
9 files changed
+392
-30
No files matched your search
@@ -3,6 +3,9 @@ use codex_core::exec::ExecCapturePolicy;
|
||||
use codex_core::exec::ExecParams;
|
||||
use codex_core::exec::process_exec_tool_call;
|
||||
use codex_core::sandboxing::SandboxPermissions;
|
||||
use codex_core::windows_sandbox::WindowsSandboxSetupMode;
|
||||
use codex_core::windows_sandbox::WindowsSandboxSetupRequest;
|
||||
use codex_core::windows_sandbox::run_windows_sandbox_setup;
|
||||
use codex_core::windows_sandbox::sandbox_setup_is_complete;
|
||||
use codex_features::Feature;
|
||||
use codex_protocol::config_types::WindowsSandboxLevel;
|
||||
@@ -229,13 +232,12 @@ fn windows_sandbox_cli_preserves_managed_deny_reads_across_launches() -> anyhow:
|
||||
\n\
|
||||
[permissions.managed-deny-test.filesystem]\n\
|
||||
\":minimal\" = \"read\"\n\
|
||||
\"{}\" = \"read\"\n\
|
||||
\":root\" = \"read\"\n\
|
||||
\"{}\" = \"write\"\n\
|
||||
\"{}\" = \"deny\"\n\
|
||||
\n\
|
||||
[permissions.managed-deny-test.network]\n\
|
||||
enabled = false\n",
|
||||
escape_toml_path(&fixture_root),
|
||||
escape_toml_path(&work),
|
||||
escape_toml_path(&denied),
|
||||
),
|
||||
@@ -262,6 +264,43 @@ fn windows_sandbox_cli_preserves_managed_deny_reads_across_launches() -> anyhow:
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial(codex_home)]
|
||||
async fn windows_elevated_setup_rejects_default_root_deny() -> anyhow::Result<()> {
|
||||
let codex_home = codex_home_for_windows_sandbox_test("windows-elevated-root-deny-codex-home")?;
|
||||
let workspace = TempDir::new()?;
|
||||
let cwd = dunce::canonicalize(workspace.path())?.abs();
|
||||
let file_system_sandbox_policy =
|
||||
FileSystemSandboxPolicy::restricted(vec![FileSystemSandboxEntry {
|
||||
path: FileSystemPath::Special {
|
||||
value: FileSystemSpecialPath::project_roots(/*subpath*/ None),
|
||||
},
|
||||
access: FileSystemAccessMode::Write,
|
||||
missing_path_behavior: None,
|
||||
}]);
|
||||
let permission_profile = PermissionProfile::from_runtime_permissions(
|
||||
&file_system_sandbox_policy,
|
||||
NetworkSandboxPolicy::Restricted,
|
||||
);
|
||||
|
||||
let err = run_windows_sandbox_setup(WindowsSandboxSetupRequest {
|
||||
mode: WindowsSandboxSetupMode::Elevated,
|
||||
permission_profile,
|
||||
workspace_roots: vec![cwd.clone()],
|
||||
command_cwd: cwd.to_path_buf(),
|
||||
env_map: HashMap::new(),
|
||||
codex_home: codex_home.path().to_path_buf(),
|
||||
})
|
||||
.await
|
||||
.expect_err("elevated setup should reject default root deny");
|
||||
|
||||
assert_eq!(
|
||||
err.to_string(),
|
||||
"elevated Windows sandbox requires effective `:root` read access"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[serial(codex_home)]
|
||||
async fn windows_restricted_token_rejects_exact_and_glob_deny_read_policy() -> anyhow::Result<()> {
|
||||
|
||||
Reference in new issue
Block a user