mirror of
https://github.com/openai/codex.git
synced 2026-11-24 15:21:20 +00:00
Route Windows sandbox proxy traffic by restricting SID (#34613)
## Why Elevated Windows sandboxes need stable managed-proxy ports while preserving the network policy and environment attribution of each sandboxed process. ## What changed - Keep shared HTTP and SOCKS5 loopback ingress listeners alive across managed-proxy instances. - Add a per-route restricting SID to elevated sandbox tokens and dispatch incoming connections to the matching proxy policy after attributing the client process. - Reject connections without exactly one registered route, remove routes when their proxy handle is dropped, and keep unsandboxed Windows launches off the managed ingress. - Provision the elevated sandbox with the configured proxy ports and local-binding setting, honoring the selected profile and CLI overrides. ## Testing - Add Windows unit tests for TCP ownership attribution, route selection, restricting-token propagation, and setup settings. - Add an end-to-end Windows test covering stable ports, isolated environment policies, HTTP and SOCKS5 routing, and route teardown. GitOrigin-RevId: 783fac6e0f904dc9bb1955b75d4a5895e8bb9690
This commit is contained in:
1 parent
dfd2d8133c
commit
999a715089
40 files changed
+2792
-191
No files matched your search
@@ -123,9 +123,30 @@ pub fn run_elevated_setup(
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "windows", test))]
|
||||
fn provisioning_settings(
|
||||
network: Option<&crate::config::NetworkProxySpec>,
|
||||
) -> std::io::Result<codex_windows_sandbox::WindowsSandboxProvisioningSettings> {
|
||||
let Some(network) = network.filter(|network| network.enabled()) else {
|
||||
return Ok(codex_windows_sandbox::WindowsSandboxProvisioningSettings::default());
|
||||
};
|
||||
Ok(codex_windows_sandbox::WindowsSandboxProvisioningSettings {
|
||||
proxy_ports: network.configured_proxy_ports()?,
|
||||
allow_local_binding: network.allow_local_binding(),
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn run_elevated_provisioning_setup(codex_home: &Path, real_user: &str) -> anyhow::Result<()> {
|
||||
codex_windows_sandbox::run_elevated_provisioning_setup(codex_home, real_user)
|
||||
pub fn run_elevated_provisioning_setup(
|
||||
codex_home: &Path,
|
||||
real_user: &str,
|
||||
network: Option<&crate::config::NetworkProxySpec>,
|
||||
) -> anyhow::Result<()> {
|
||||
codex_windows_sandbox::run_elevated_provisioning_setup(
|
||||
codex_home,
|
||||
real_user,
|
||||
provisioning_settings(network)?,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
@@ -140,7 +161,11 @@ pub fn run_elevated_setup(
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
pub fn run_elevated_provisioning_setup(_codex_home: &Path, _real_user: &str) -> anyhow::Result<()> {
|
||||
pub fn run_elevated_provisioning_setup(
|
||||
_codex_home: &Path,
|
||||
_real_user: &str,
|
||||
_network: Option<&crate::config::NetworkProxySpec>,
|
||||
) -> anyhow::Result<()> {
|
||||
anyhow::bail!("elevated Windows sandbox setup is only supported on Windows")
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user