Skip to content

feat: make sandbox read access configurable with ReadOnlyAccess#11387

Merged
bolinfest merged 1 commit intomainfrom
pr11387
Feb 12, 2026
Merged

feat: make sandbox read access configurable with ReadOnlyAccess#11387
bolinfest merged 1 commit intomainfrom
pr11387

Conversation

@bolinfest
Copy link
Collaborator

@bolinfest bolinfest commented Feb 11, 2026

SandboxPolicy::ReadOnly previously implied broad read access and could not express a narrower read surface.
This change introduces an explicit read-access model so we can support user-configurable read restrictions in follow-up work, while preserving current behavior today.

It also ensures unsupported backends fail closed for restricted-read policies instead of silently granting broader access than intended.

What

  • Added ReadOnlyAccess in protocol with:
    • Restricted { include_platform_defaults, readable_roots }
    • FullAccess
  • Updated SandboxPolicy to carry read-access configuration:
    • ReadOnly { access: ReadOnlyAccess }
    • WorkspaceWrite { ..., read_only_access: ReadOnlyAccess }
  • Preserved existing behavior by defaulting current construction paths to ReadOnlyAccess::FullAccess.
  • Threaded the new fields through sandbox policy consumers and call sites across core, tui, linux-sandbox, windows-sandbox, and related tests.
  • Updated Seatbelt policy generation to honor restricted read roots by emitting scoped read rules when full read access is not granted.
  • Added fail-closed behavior on Linux and Windows backends when restricted read access is requested but not yet implemented there (UnsupportedOperation).
  • Regenerated app-server protocol schema and TypeScript artifacts, including ReadOnlyAccess.

Compatibility / rollout

  • Runtime behavior remains unchanged by default (FullAccess).
  • API/schema changes are in place so future config wiring can enable restricted read access without another policy-shape migration.

Copy link
Contributor

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9fe4ec9567

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 653 to 654
let mut roots = read_only_access.get_readable_roots_with_cwd(cwd);
roots.extend(writable_roots.clone());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include implicit writable roots in WorkspaceWrite read set

When WorkspaceWrite uses restricted read access, this code only merges read_only_access roots with the explicitly configured writable_roots, but it skips the implicit writable roots added elsewhere (cwd, /tmp, and optionally TMPDIR). That creates a mismatch where default workspace paths remain writable but are not readable, so commands can fail in restricted-read mode on the Seatbelt backend unless callers manually duplicate those paths in readable_roots.

Useful? React with 👍 / 👎.

@bolinfest bolinfest force-pushed the pr11387 branch 8 times, most recently from adca2d9 to 9132f09 Compare February 11, 2026 18:23
@bolinfest bolinfest changed the title Make sandbox read access configurable with ReadOnlyAccess feat: make sandbox read access configurable with ReadOnlyAccess Feb 11, 2026
@bolinfest bolinfest force-pushed the pr11387 branch 8 times, most recently from 2c0af3f to 1245a70 Compare February 12, 2026 00:54
@bolinfest bolinfest requested a review from viyatb-oai February 12, 2026 01:06
## What

This change introduces a new `ReadOnlyAccess` model and threads it through
sandbox policy consumers so read access is explicit instead of implicit.

- Added `ReadOnlyAccess` to protocol:
  - `Restricted { include_platform_defaults, readable_roots }`
  - `FullAccess`
- Changed `SandboxPolicy` shape:
  - `ReadOnly` is now `ReadOnly { access: ReadOnlyAccess }`
  - `WorkspaceWrite` now carries `read_only_access: ReadOnlyAccess`
- Kept existing behavior for now by defaulting to `ReadOnlyAccess::FullAccess`
  in constructors and current config/app-server mappings.
- Added helper methods to compute effective readable roots (including optional
  platform defaults + cwd) and to detect full read access.
- Updated seatbelt policy generation to honor restricted read roots by emitting
  scoped `(allow file-read* ...)` entries when full read access is not granted.
- Updated Linux backends (`bwrap`, legacy landlock path) to fail closed with an
  explicit `UnsupportedOperation` when restricted read access is requested but
  not yet implemented there.
- Updated Windows sandbox backends (standard, elevated, and runner paths) to
  fail closed in the same way for restricted read access.
- Updated all call sites/tests/pattern matches for the new structured variants
  and regenerated app-server protocol schema/types.

## Why

The previous `SandboxPolicy::ReadOnly` implied full-disk read access and left
no way to express a narrower read surface.

This refactor establishes the policy model needed to support user-configurable
read restrictions in a follow-up without changing current runtime behavior.

It also ensures we do not silently ignore future restricted-read policies on
platform backends that do not support them yet. Failing closed keeps sandbox
semantics predictable and avoids accidental over-permission.

## Compatibility and rollout notes

- Existing behavior is preserved by default (`FullAccess`).
- Existing config/app-server flows continue to serialize/deserialize cleanly.
- New schema artifacts are included to keep generated protocol outputs in sync.

## Validation

- `just fmt`
- `just fix -p codex-protocol -p codex-core -p codex-linux-sandbox -p codex-windows-sandbox -p codex-app-server-protocol`
- `cargo check -p codex-windows-sandbox`
- Targeted crate/test runs were executed during development for protocol/core/
  sandbox-related crates.
@bolinfest bolinfest merged commit abbd74e into main Feb 12, 2026
70 of 85 checks passed
@bolinfest bolinfest deleted the pr11387 branch February 12, 2026 02:31
@github-actions github-actions bot locked and limited conversation to collaborators Feb 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants