Commit Graph

7 Commits

Author SHA1 Message Date
chess
665e5f45ab Clean up Windows sandbox resources on app uninstall (#42375)
## What changed

- Record the authenticated sandbox owner and observe package uninstall events across service restarts and session changes.
- During uninstall, serialize setup and cleanup, disable sandbox accounts, stop their processes, and remove sandbox directories, firewall and WFP rules, hidden-user entries, accounts, and the sandbox group.
- Restrict desktop-owned directory cleanup to pinned paths and perform it while impersonating the authenticated owner.
- Detect missing or disabled sandbox accounts after interrupted cleanup and reprovision them before restoring network access.

GitOrigin-RevId: 7d63fff7ddcff3eb01d018653146df12044bd277
2026-09-02 22:19:51 +00:00
johnl-oai
830363bd7c Add experimental Windows sandbox service provisioning (#42353)
## What changed

- Add the default-off `windows_sandbox_service` feature and expose it through
  app-server experimental feature enablement.
- When enabled, attempt service provisioning during elevated Windows sandbox
  setup, using the effective network proxy ports and listener roles. Continue
  through the existing setup path when the service is unavailable or the
  configuration is unsupported.
- Report unsupported Codex home drives as service unavailability so the client
  can fall back to the elevated helper.

## Testing

- Add a Windows-only unit test covering HTTP and SOCKS listener derivation from
  the effective proxy configuration.

GitOrigin-RevId: 40b119cf51f84e5d0e94d6a0a8d5b506d1123526
2026-09-02 20:30:45 +00:00
johnl-oai
7e45bdb5fd Enable authenticated Windows sandbox provisioning (#42351)
## Why

The Windows sandbox service had provisioning policy and client authentication in place, but its IPC listener was still disabled.

## What changed

- Serve framed provisioning requests over a local named pipe, authenticate packaged clients, validate requests and machine policy, and report provisioning outcomes through bounded responses and Windows event logging.
- Return `unavailable` for configuration parse failures so clients can fall back to the elevated setup helper.
- Keep validated directory handles alive in the setup helper so path protections survive an unexpected service exit.
- Make connection recovery and shutdown wakeups tolerate clients that disconnect before the listener accepts them.

## Testing

Added Windows tests for response framing, configuration-error classification, pipe security and reconnect behavior, shutdown wakeups, and retained helper handles.

GitOrigin-RevId: 68e9d546dcada88ff162ea4f98c0f4d748706b34
2026-09-02 20:27:05 +00:00
johnl-oai
4fdf4c1113 Add Windows sandbox client authentication (#42348)
## Why

Sandbox provisioning IPC must authenticate callers before request handling can be enabled.

## What changed

- Authorize named-pipe clients against the Codex package identity and keep the client process open through authentication.
- Impersonate the caller and require its token to match the client process user, belong to an interactive named user, and not belong to the sandbox group.
- Prepare and pin the requested Codex home, then validate machine policy with the impersonated token.
- Allow known Codex package families when running an unpackaged debug service in foreground mode.

Provisioning IPC remains disabled until this authentication is connected to the transport.

## Testing

- Add a Windows test that verifies an unpackaged pipe client is rejected before it sends a provisioning request.

GitOrigin-RevId: b0e87450c06f8de3eca6cb77daa9b11ef80699a9
2026-09-02 20:14:42 +00:00
johnl-oai
c4ea7294b9 Prepare managed policy validation for Windows sandbox provisioning (#42344)
## What changed

- Add a Windows sandbox service validator that loads managed configuration while impersonating the provisioning client.
- Reject elevated sandbox or network settings that conflict with managed requirements, including local binding and HTTP or SOCKS proxy-port restrictions.
- Add a one-shot cloud configuration loader that bypasses the disk cache so policy checks use a fresh backend response without modifying cached configuration.
- Keep the provisioning integration disabled until authenticated transport can supply the policy inputs.

## Testing

- Cover elevated sandbox restrictions, disabled networking, local binding, proxy-port classification, malformed policy, impersonation failure, and cache bypass behavior.

GitOrigin-RevId: b76aa8959c515c6507c2eaf61af768efa1305253
2026-09-02 20:07:11 +00:00
johnl-oai
add870a4bf Harden Windows sandbox provisioning file handling (#42342)
## Why

Windows sandbox provisioning performs privileged work beneath a requested Codex home. Provisioning paths and output entries must remain bound to the files and directories that were validated, without following reparse points or writing through caller-controlled hard links.

## What changed

- Add reusable no-reparse directory opens, path validation, directory guards, and handle-relative atomic file replacement.
- Use fresh or retained handles for provisioning logs, sandbox credentials, setup markers, and error reports in service provisioning mode.
- Add service-side validation for framed provisioning requests, proxy settings, fixed-drive Codex homes, and pinned sandbox directories.

## Testing

Add Windows tests covering junction and unsafe-path rejection, hard-link-safe output replacement, retained output handles, request framing and normalization, and ancestor pinning.

GitOrigin-RevId: 2ec4f0d15404c3387df1414bb0c1915cf452ecf2
2026-09-02 20:03:43 +00:00
johnl-oai
501931b399 Add Windows sandbox service lifecycle scaffolding (#42341)
## What changed

- Add the `codex-windows-sandbox-service` workspace crate and Windows-only build target.
- Integrate `CodexSandboxService` with the Windows Service Control Manager, including start, stop, shutdown, status reporting, and event-log handling.
- Support service mode by default and a debug-only `--foreground` mode. Keep provisioning IPC disabled until authenticated request handling is available.

## Testing

- Add argument-parsing tests for service, foreground, unknown, and multiple arguments.

GitOrigin-RevId: 1c84f0a593b65e5cf97ab7606cde03675542b0b0
2026-09-02 19:49:58 +00:00