Skip to content

ci: native Claude tests can escape offline isolation through managed settings #4313

Open

Description

@schlessera

Out of scope

No change to production authentication or managed-policy precedence. No real credentials, endpoint names, host identifiers, or deployment configuration belong in this issue. Do not rerun the unsealed counterexample against a real provider.

Context

Found while qualifying #4274 in PR #4312 at accf202cf39c871f9ad4697d1df3eb2df761f546.

voyageHome in packages/ui-server/tests/safety-result-retention.test.ts:58-190 launches the installed Claude SDK runtime with a temporary HOME/config directory, settingSources: [], a fake API key and a scripted loopback ANTHROPIC_BASE_URL. The native runtime nevertheless returned generated assistant text while that scripted origin recorded zero requests. This invalidates the native test premises and their qualification receipts.

A machine-level managed settings file can override the test's API endpoint and configure an API-key helper. The observed helper resolved its credential storage through the OS account identity rather than HOME; real credential material was present outside the fixture. No secret values are included here. The configured managed endpoint was non-loopback. The stream/routing evidence establishes the harness escape; historical socket/DNS attribution and the upstream request count were not retained, so no specific packet destination or count is claimed.

The preload guard in scripts/test-network-guard.ts:29-165 instruments Bun/JavaScript transports and Bun subprocesses, but the SDK spawns the native runtime through a separate child-process path. Its native traffic and helper access were not intercepted or recorded. scripts/test.ts:240-248 and scripts/test-home.ts:66-81 isolate invoking HOME storage, which does not hide machine-managed settings or an OS-account helper's storage.

Before any correction, the whole retention file produced 0 pass / 9 fail; the full eight-file focused set produced 228 pass / 9 fail. Two failures were a separate fixture ReferenceError; seven native cases failed their runtime premises. These are failed receipts, not passing offline proof.

Scope

Make the installed-native test path genuinely offline and credential-isolated, including managed settings, helper processes and native subprocess networking. The boundary must fail before launching an unqualified native process when isolation is unavailable. Preserve the existing product guards and the provider-history assertions.

Design (maintainer rulings, 2026-11-23)

These supersede the per-stage inspection design. Sources: ruling 1 (its product-time acknowledgement rule still applies), redesign and fallback, option F2.

  • The test runner runs offline, in a network namespace that has only loopback. Host Claude Code managed settings are hidden, and credential environment is stripped. The stub mask over known native install paths stays, and so does the non-loopback network preload. Per-stage inspection is dropped.
  • Default: a root-created offline network and mount namespace that keeps the real user and group IDs.
  • Fallback when that is unavailable: a qualified rootless subset, built from user, network and mount namespaces with loopback only, plus the runtime masks, hidden managed settings, IPC restrictions and a scrubbed environment. Ordinary tests and compatible native tests run in it. The separate-UID, root-bwrap and setpriv suites are refused before execution, with a fixed reason recorded.
  • When neither namespace can be created, the whole run stops before any test module loads, with a clear setup error. A "partial" mode that refuses only the native files and runs the rest without a sandbox is rejected.
  • The product's 10 s acknowledgement promise is unchanged.

Acceptance criteria

  • A keyless fixture supplies hostile managed settings and a helper that would read a sentinel credential outside HOME. Neither the helper nor the native runtime can read that credential or reach an unintended destination.
  • Native subprocess access is restricted to the exact scripted loopback service; this is enforced independently of the SDK's endpoint/configuration choices.
  • Missing isolation refuses the test before native launch, with an explicit failed receipt; it is never a skip or a passing fallback.
  • The guard records denied native attempts without logging credential values, and a restored mutation proves the managed-config escape is detected.
  • Proof shows that no test needs non-loopback network, and that hosted CI runners and a local host can create the default namespace. It also exercises the rootless subset, with its refused suites and their recorded reason, and the stop-before-load setup error.
  • The native backend, provider-history and baseline retention suites already available on main pass in the qualified hosted environment; each receipt names its exact head and complete test inventory. The baseline retention fixture must use the generic boundary with its synthetic search-wrapper PATH, USE_BUILTIN_RIPGREP, selective mounts and positive invocation witnesses. PR CONTRACT: retain ambiguous tool delivery and incomplete search evidence #4312 changes that existing suite: its changed retention implementation and complete changed-head qualification remain part of ui-server: retain unknown delivery for concurrent reused tool IDs #4274 / PR CONTRACT: retain ambiguous tool delivery and incomplete search evidence #4312 after the generic boundary lands; do not import those implementation changes here.

Verification

No real provider key, remote model, external network or paid inference. Use controlled loopback fixtures and an enforced native network/credential boundary. Retain the incident's failed receipts separately from later proof. PR #4312's native qualification remains unfinished until this boundary is established.

Contract impact

Test-harness enforcement only; no production CLI, MCP, frontmatter or provider-history contract changes. Managed settings remain authoritative in production. Remediation proceeds after maintainer direction; the unsafe native probes have stopped.

Related: #4274, #4312.

2026-11-20 scope correction: the baseline retention file is already present at main base 099683923ff8764686c9b92fc2dfb021f1d01f67 (introduced by PR #3827). #4313 qualifies the generic boundary and existing main suites, including that baseline fixture. #4274 / PR #4312 retain their changed retention implementation and complete changed-head qualification. The earlier statement that the suite was absent from main was incorrect.

2026-11-23 triage at main 356fa7d76: folded today's three maintainer rulings into a Design section and added the namespace proof criterion. The scope and other criteria are unchanged.

Activity

  1. added
    type: fixSomething is broken and must behave the way it is documented.
    area: backendsAgentBackend implementations and the seam they share.
    area: ciCI workflows, the gates they run, release scripts, packaging.
    priority: p1Scheduled into the current or next milestone.
    securityAuth, isolation, egress, secrets, or anything in the threat model.
    on Nov 20, 2026
  2. added this to the 0.45.0 milestone on Nov 20, 2026
  3. self-assigned this
    on Nov 20, 2026
  4. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    Claiming #4313 for the test-only OS isolation boundary on branch fix/native-claude-isolation (claim token native-boundary-4313). Unqualified direct native launches now refuse before process creation with an explicit failed receipt. Local verification remains limited to refusal and non-native checks; positive native proof will run only in hosted CI. The retention suite in #4312 remains separate.

  5. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    2026-11-20 acceptance clarification: the retention suite is present only in PR #4312 and does not exist on main. Its instrumented rg integration and complete hosted retention qualification have therefore moved explicitly to #4274 / PR #4312. This issue retains the generic OS boundary, hostile managed-settings/helper proof, and passing hosted native backend/provider-history receipts for the final head with the complete inventory. The body reflects that split; the re-review finding about retention qualification is filed to #4274.

  6. schlessera commented on Nov 20, 2026

    @schlessera
    OwnerAuthor

    2026-11-20 source correction: the baseline packages/ui-server/tests/safety-result-retention.test.ts already exists at main base 099683923ff8764686c9b92fc2dfb021f1d01f67 (introduced by PR #3827). The earlier absent-from-main rationale was incorrect. #4313 / PR #4314 must support and qualify that existing baseline through the generic boundary, including its synthetic search-wrapper inputs. #4274 / PR #4312 retain their changed retention implementation and complete changed-head qualification after the boundary lands. No PR #4312 implementation changes were imported into PR #4314. Historical failed receipts remain failed.

  7. schlessera commented on Nov 22, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-22): keep fixing PR #4314 until a complete heavy run is green.

    Why the question came up. At fix-check round 20, heavy run 44956104575 at 08c9be524 showed:

    • Native cells: nearly green. Behavior passes 12/12 and credentials 5/5. Enforcement passes 13/15; the two failures are RTK, from PATH equality at worker-rtk.ts:81. In identity, the fresh, warm and control phases pass, and strict fails admission.
    • Regressions from earlier pushes of fix(ci): isolate native Claude tests from host managed settings #4314: 8 unit and 3 browser jobs failed.
      • Missing modules in the guard copy closure.
      • The receipt file descriptor fails across user namespaces.
      • The guard forces nonessential-traffic suppression.
      • DISABLE_PROMPT_CACHING is stripped.
      • A dynamic fixture shell is classified as native.
      • The runtime probe lacks scripted authority.

    Options considered:

    • Keep fixing (chosen).
    • Narrow the guard to the installed-native suites only.
    • Pause the PR.

    Conditions on the chosen path:

    • Every attributed regression is fixed.
    • An invariant test checks that the guard's environment equals the product's for every native launch path, apart from an explicit allowlist of keys the guard owns.
    • The unit and browser categories are proven locally under the guard before the next push.
  8. schlessera commented on Nov 22, 2026

    @schlessera
    OwnerAuthor

    Design note (orchestrator, 2026-11-22), for PR #4314.

    Under fail-closed classification, launches the guard couldn't classify, such as keyless test shells with loops or a positional exec "$1", were refused at admission. That broke ordinary unit tests in each of the last four hosted rounds.

    What I changed, following the "restrict before refusing" rule:

    • An unknown-class launch now runs in its normal view.
    • Every installed or selected native runtime path (realpath targets and aliases included) is replaced by a file-over-file bind of a fixed tripwire stub. The stub records a refusal and exits non-zero.
    • Native code therefore never executes, and harmless shells are unaffected.
    • Where the mask can't be applied, the launch refuses.
    • Positively native launches keep their admission-time agreement and authority checks.

    Residual gap. A hash-equal copy of a runtime at a path the script computes itself would not be masked.

    • It is covered as a diagnostic by the existing argv detection and by exec-audit detection.
    • A deny-all network backstop for unknown launches is deferred to ci: harden native fixture stderr privacy, bounds and shutdown cleanup #4410. It cites the design review's bypass table (inherited sockets and directory fds, vsock and other socket families, datagram sends, keyrings, the receipt channel).

    The independent design review recommended this as the primary control (option O1), over a deny-all execution sandbox. The sandbox would have added a new compatibility surface and a new class of trace flake.

  9. schlessera commented on Nov 22, 2026

    @schlessera
    OwnerAuthor

    Correction to the 2026-11-22 design note (PR #4314): the residual gap under O1 is wider than "a hash-equal copy at a computed path."

    Inside an existing bwrap, the tripwire masks only cover the runtimes' host realpaths. If that sandbox binds the runtime directory to another destination, the runtime is visible unmasked there. Reaching it still requires the script to compute that remapped path itself: a literal native path classifies as native and goes through admission.

    The durable fix is to mask each runtime at every destination an existing bind maps it to. That is tracked in #4410 with the deny-all backstop.

    Known O1 limits, also recorded in #4410:

    • an unknown launch's own fatal signal is reported as exit code 139 rather than as a signalCode;
    • the payload runs with NoNewPrivs, is ptrace-traced, and runs in a user namespace;
    • on hosts that restrict unprivileged user namespaces, a harmless shell that itself starts bwrap is denied by host policy.
  10. schlessera commented on Nov 22, 2026

    @schlessera
    OwnerAuthor

    Fable fix check 23 clarifies the existing O1 residual: besides rebinding a runtime directory at another destination, a launch can obtain native bytes through an inherited or unlinked descriptor and copy them to a computed executable path. Installed/canonical/alias path masks do not cover every such byte source. Exec auditing remains diagnostic and is not a synchronous execution barrier for that case. The durable follow-up is filed on #4410; this is a widened residual statement, not a completed fix or additional authority.

  11. schlessera commented on Nov 22, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-22, second ruling): keep the guard global, wrapping every suite, and fix the remaining regression groups one by one.

    The alternative put to the maintainer was to make the guard opt-in, limited to the statically inventoried native-capable files. It was declined.

    Status at heavy run 45014338287 (PR #4314 head 906745512):

    • The keeper-startup class is fixed: 131 failures in the previous round, 0 now.
    • Native runtime probes pass 12/12. Credentials pass 5/5. Enforcement passes 14/15.
    • 33 unit failures remain, in 12 groups (U1–U12), and are tracked on the PR.
  12. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Maintainer ruling (PR #4314, strict native acknowledgement overrun: 10.5 s raw against the 10 s promise, of which the test guard accounts for 6.6 s):

    1. The product's 10 s acknowledgement promise is unchanged. Under the guard, it is asserted on product time: wall-clock time minus the guard's own recorded, non-overlapping intervals inside the window. The raw time is recorded too, with a catch-all bound. A mutation that delays the product path must still fail the assertion.
    2. Guard findings and setup are reused across tests in one process, on the assumption that the environment does not fundamentally change between tests. Per-entry findings are keyed on file identity and metadata. The complete freshness check still runs before every launch, and a new, missing or changed entry is re-inspected or refused, never assumed clean.
    3. The guard inspects stage files in place through its pinned descriptors where the launch view allows, and falls back to copying per path otherwise.
  13. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Maintainer ruling (PR #4314, 2026-11-23). The per-stage inspection guard did not converge: each heavy run surfaced new stage roles and conflicts, the guard took about 65% of native acknowledgement time, and its audit sandbox conflicts with the product's disabled nested user namespaces.

    The guard is redesigned around the routes a real provider call needs, instead of around every stage layout:

    • The test runner runs offline, in a network namespace with loopback only.
    • The host's Claude Code managed settings are hidden, and credential environment is stripped.
    • The stub mask over known native install paths stays.
    • The existing non-loopback network preload stays.
    • Per-stage inspection is dropped.

    Proof must show that no test needs non-loopback network, and that CI runners and local hosts can create the namespace. Where the namespace cannot be created, only native-launching tests refuse; everything else still runs.

  14. schlessera commented on Nov 23, 2026

    @schlessera
    OwnerAuthor

    Maintainer ruling on the offline-runner fallback (design v2, option F2), 2026-11-23:

    • The default is the root-created offline network and mount namespace, keeping the real user and group IDs.
    • When that is unavailable, a qualified rootless subset runs: user, network and mount namespaces with loopback only, the runtime masks, the hidden managed settings, IPC restrictions and a scrubbed environment. Ordinary tests and compatible native tests run in it. The separate-UID, root-bwrap and setpriv suites are refused before execution, with a fixed reason recorded.
    • When neither can be created, the whole run stops before any test module loads, with a clear setup error. No host runs tests with a route to a real provider. The degraded "partial" mode (refusing only the native files and running the rest without a sandbox) is rejected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: backendsAgentBackend implementations and the seam they share.area: ciCI workflows, the gates they run, release scripts, packaging.priority: p1Scheduled into the current or next milestone.securityAuth, isolation, egress, secrets, or anything in the threat model.type: fixSomething is broken and must behave the way it is documented.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions