Commit Graph

10 Commits

Author SHA1 Message Date
viyatb-oai
99914f4950 Honor explicit Unix socket grants in the Linux managed sandbox (#45534)
## Why

Linux proxy-routed sandboxing denied standalone Unix sockets even when the effective network policy enabled `dangerously_allow_all_unix_sockets`.

## What changed

- Carry Unix socket permissions in `ManagedNetworkSandboxContext` and pass the prepared context through Linux sandbox launches with `--managed-network`.
- Allow `AF_UNIX` socket creation in proxy-routed mode when `dangerously_allow_all_unix_sockets` is enabled, while preserving network namespace isolation and restrictions on other socket families.
- Keep standalone Unix sockets denied by default and for path-only grants. Default missing fields in older serialized contexts to restrictive values.

## Testing

Add coverage for policy preparation and transport, legacy deserialization, and malformed policy rejection. Add a Linux integration test covering default denial, path-only denial, and explicit allow-all access, while checking that direct TCP access and `AF_NETLINK`/`AF_VSOCK` sockets remain blocked.

GitOrigin-RevId: 2695b945ad3e59fcb3faf7662d852a26650af16c
2026-09-14 22:40:20 +00:00
iceweasel-oai
c379459bba Wire the Windows MXC sandbox into command execution (#45176)
## What changed

- Add explicit MXC backend selection and carry its identity through exec-server process reporting and sandbox violation classification.
- Launch MXC through the Codex executable with the effective permission profile and command environment.
- Reject exec-server MXC requests when native MXC is unavailable or when they request a TTY, an `arg0` override, or managed networking. Reject private desktop isolation during MXC preparation.
- Allow an explicitly empty child environment and avoid exposing request payload values in launcher decode errors.

## Testing

Add coverage for sandbox selection and unsupported-request rejection, plus Windows RPC tests for stdin writes and temporary-directory permissions derived from the command environment. Native MXC tests skip when MXC is unavailable.

GitOrigin-RevId: 3626ff0f9ad7f9b812ce09b68c31ea9a5a9c72b1
2026-09-13 06:07:03 +00:00
iceweasel-oai
42cd1ec497 Wire up the native Windows MXC helper entry point (#44903)
## What changed

- Dispatch `--__codex-windows-mxc` before normal CLI parsing, launch the decoded request, and propagate the child exit code.
- Build the native request from the helper's environment and working directory, discovered Windows platform directories, and volume roots, including UNC working-directory roots. Reject non-Unicode environment values and empty child environments.
- Allow Win32k calls and desktop handles needed for PowerShell startup while retaining clipboard, input-injection, and desktop/system-control restrictions.
- Keep policy, transport, and native launch internals private, and report an explicit error when the helper is invoked outside Windows.

## Testing

Add a wrapper regression test covering exact argument preservation, Windows quoting, separate policy and command working directories, and explicit environment forwarding.

GitOrigin-RevId: 674d0d61a3265bd517b77da9f9de2cd9fad62917
2026-09-11 20:10:02 +00:00
iceweasel-oai
2c9e1a5775 Add managed network policy support to the Windows MXC sandbox (#44872)
## What changed

Add `create_command_args()` to encode argv, permissions, policy cwd, and optional managed network context through the existing bounded environment transport.

For managed networking, generate a policy that allows IPv4 and IPv6 loopback while denying direct non-loopback egress and general inbound access. Require nonempty, nonzero proxy ports and reject `allow_local_binding=false` at both launcher and policy boundaries because native host-loopback access is bidirectional.

Document the MXC launch contract, platform requirements, and limitations.

## Testing

Add portable tests covering managed network transport and policy translation, plus rejection of missing proxy ports, zero ports, and unsupported local-binding restrictions at both boundaries.

GitOrigin-RevId: 8d31b98f94a2ba3769369aa50de8e53dc143bac4
2026-09-11 17:19:23 +00:00
iceweasel-oai
4150a2c205 Add bounded environment transport for MXC launch requests (#44626)
## Why

Sandbox policies can exceed Windows command-line limits. Provide an environment transport for these larger MXC launch requests.

## What changed

- Make `MxcCommand` serializable and add JSON encoding and decoding through `CODEX_MXC_LAUNCH_*` environment variables.
- Split payloads into UTF-8-safe chunks of at most 4,096 bytes, with a 1,000,000-byte payload limit and at most 256 chunks.
- Reject malformed or duplicate transport entries and remove all transport variables during decoding, including on failure. Preserve unrelated environment variables.

## Testing

Add tests for large Unicode and escaped-argument round trips, stale variable removal, malformed transport rejection and cleanup, and oversized payload rejection without modifying the environment.

GitOrigin-RevId: 0e5ae2535ef313985a95eb8a5fd4884974dfb1eb
2026-09-10 19:29:54 +00:00
iceweasel-oai
5c013177d8 Support temporary and minimal filesystem grants in MXC (#44620)
## Why

MXC rejected symbolic temporary-directory and minimal filesystem entries, preventing policies using them from reaching execution.

## What changed

- Resolve `Tmpdir` entries from absolute `TEMP` and `TMP` paths in the filtered command environment, matching variable names case-insensitively.
- Ignore `SlashTmp` entries because `/tmp` has no special meaning on the Windows executor.
- Include platform read roots when the policy requests platform defaults, preserving explicit denies.

## Testing

Add coverage for temporary paths and invalid environment values, optional platform roots, explicit denies, empty commands, and Windows case-insensitive read/write overrides.

GitOrigin-RevId: feb69157ff35bcf648fa0ed0e7d4376818bc1941
2026-09-10 18:57:16 +00:00
iceweasel-oai
d1696652a2 Support symbolic :root filesystem policies in MXC (#44580)
## Why

MXC rejected filesystem policies containing `:root` or granting full disk write access, preventing these policies from being translated into native grants.

## What changed

- Resolve `:root` against every executor volume before applying permission precedence and read-only carveouts.
- Grant full disk write access across enumerated volumes while preserving explicit writable paths outside them, such as unmapped shares.
- Treat a `:root` deny as the default so narrower explicit grants survive, while retaining explicit path denies.
- Continue rejecting unsupported symbolic paths with a more specific error.

## Testing

Add regression tests for precedence across drives and working directories, volume grant expansion, explicit grants outside enumerated volumes, root denies with narrower grants, and restrictions on one volume preserving grants on another.

GitOrigin-RevId: 94c9fec9e6429913714ebbdeca382c4f1624b5a2
2026-09-10 16:42:34 +00:00
iceweasel-oai
d117c2eb02 Expand MXC volume grants and resolve deny globs (#44289)
## Why

MXC volume-root grants are nonrecursive, and filesystem deny globs were rejected before launch.

## What changed

- Expand volume-root grants to include existing immediate children, preserving read-only carveouts and denies. Children created directly under a volume root after policy construction are not granted access.
- Normalize filesystem object aliases before and after expansion so generated grants preserve tighter access restrictions.
- Skip unavailable volumes and uninspectable generated children.
- Resolve deny globs into concrete file and directory paths using the Windows sandbox resolver.

## Testing

Add regression tests for read-only children and aliases, normalized root access, uninspectable children, and deny glob expansion alongside explicit denies.

GitOrigin-RevId: 3242e9a30d16581d6fe5b7b6e39e0e0f71ca6ef4
2026-09-09 20:02:40 +00:00
iceweasel-oai
ce254df05a Add canonical permission translation for MXC execution requests (#43853)
## What changed

Add `policy::build_request` to `codex-rs/mxc-sandbox` to translate `MxcCommand` permissions into native MXC execution requests. Preserve filesystem denies, read-only carveouts, and protected metadata paths, and resolve overlapping grants using canonical path identities.

Map network permissions to ingress, egress, and loopback policies; quote arguments for Windows process creation; and disable DACL mutation fallback. Reject unsupported symbolic roots and deny globs, empty commands, relative working directories, and non-Unicode request paths.

## Testing

Enable unit tests and add coverage for filesystem grants and carveouts, disabled DACL mutation, deny-glob rejection, relative working directories, and non-Unicode paths.

GitOrigin-RevId: 3e647ed5fa932ab9d528eb44a49dd9283ef50481
2026-09-08 16:38:25 +00:00
iceweasel-oai
60888d0868 Add a native Windows MXC sandbox adapter (#42841)
## What changed

- Add `codex-mxc-sandbox` with native MXC availability detection and a launcher that inherits standard I/O and waits for the sandboxed process.
- Reject unsupported learning-mode and fallback policies, and verify deny-path support before launch.
- Route the existing Windows MXC availability metric through the new crate and move its Windows linking dependencies alongside the adapter.

GitOrigin-RevId: e2a220b85718e00b0e710c30bbe66b6c56958176
2026-09-04 20:09:04 +00:00