Honor the configured Windows sandbox level for managed networking (#37875)

## Why

Managed networking implicitly selected the elevated Windows sandbox backend,
even when the sandbox was configured to use a restricted token.

## What changed

- Select the Windows sandbox backend solely from `WindowsSandboxLevel`.
- Reject managed networking with a restricted-token sandbox before spawning a
  process, since managed networking requires the elevated backend.
- Cover the rejection through sandbox preparation, unified exec, and Windows
  sandbox session tests.

GitOrigin-RevId: 308858652d7b629af623d22896dafde3a23d3758
This commit is contained in:
iceweasel-oai authored and copyberry committed 2026-08-10 19:57:40 +00:00
1 parent 46f5d6eba9
commit a603d7ca5c
9 files changed
+134 -56

No files matched your search

+15 -7
View File
@@ -404,11 +404,20 @@ impl SandboxManager {
)
}
#[cfg(target_os = "windows")]
SandboxType::WindowsRestrictedToken => (
os_argv_to_strings(argv),
None,
Some(pending_sandboxed_request?),
),
SandboxType::WindowsRestrictedToken => {
if enforce_managed_network && windows_sandbox_level != WindowsSandboxLevel::Elevated
{
return Err(SandboxTransformError::WindowsSandboxPreparation(
"managed networking requires the elevated Windows sandbox backend"
.to_string(),
));
}
(
os_argv_to_strings(argv),
None,
Some(pending_sandboxed_request?),
)
}
#[cfg(not(target_os = "windows"))]
SandboxType::WindowsRestrictedToken => (
os_argv_to_strings(argv),
@@ -524,8 +533,7 @@ fn wrap_windows_sandbox_exec_request_for_direct_spawn(
})
})
.transpose()?;
let use_elevated =
windows_sandbox_uses_elevated_backend(request.windows_sandbox_level, proxy_enforced);
let use_elevated = windows_sandbox_uses_elevated_backend(request.windows_sandbox_level);
let overrides = if use_elevated {
resolve_windows_elevated_filesystem_overrides(
request.sandbox,