Skip to content

feat(gateway): Every grant worker confines itself before it reads any input - #26

Merged
sodre merged 8 commits into
mainfrom
docs/18-worker-sandbox
Nov 20, 2026
Merged

sodre merged 8 commits into
mainfrom
docs/18-worker-sandbox

Conversation

@sodre

@sodre sodre commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Closes #22

Summary

Every grant worker now locks itself down before it reads anything: its memory cannot be read by another process, Landlock gives it no file or network access where the kernel has Landlock, and the kernel kills it on any system call a grant worker does not need. The Gateway logs these layers at startup, and when the kernel kills a grant worker this way the log says so and that grant needs fresh approval.

countersign-gateway grant-worker            (inside bubblewrap, as before)
  worker_sandbox::confine()                 new, public: Layers or ConfineError{layer}
    non-dumpable
    no_new_privs
    Landlock: every right of the kernel's ABI handled, none granted (or "unavailable")
    seccomp allow-list: default kills the process
  worker::serve(layers)                     first read of the control socket

supervisor
  startup probe  -> "Gateway worker sandbox "namespaces": namespaces, non-dumpable, Landlock ABI v7, seccomp allow-list"
  worker ends    -> "Gateway grant <id>: grant worker killed by the worker sandbox's filter (SIGSYS); grant fenced"

Choices the ticket left open:

  • confine() takes no worker sandbox argument. The base layers are the same under both sandboxes, so the argument would do nothing yet. Operators can choose the filter sandbox #23 Operators can choose the filter sandbox adds the choice.
  • no_new_privs is set before Landlock, not after it. The ticket lists it with the allow-list, third. An unprivileged landlock_restrict_self fails with EPERM without it (landlock_restrict_self(2)), so it has to come second. A failure to set it is reported under the allow-list, the layer it belongs to.
  • Conditional rules. kill and tgkill only for the grant worker's own process ID. sendto only with a null destination, since Rust writes a stream with it. fcntl only for the three commands a grant worker uses, which keeps F_SETOWN from having the kernel signal another process. ioctl only for FIONBIO, socketpair only for AF_UNIX. clone only with CLONE_THREAD, for hosts whose profile answers clone3 with ENOSYS, as Docker's default does.
  • The startup probe reports from a thread with an async runtime, where a connection is served, so a host the allow-list cannot serve on fails at startup and not on the first grant.
  • A grant worker that ends on its own is fenced when it ends, whatever the cause, and one line is logged. Before, it was fenced when the next connection failed to attach.
  • tests/runtime.py is extended, not rewritten: it now asserts the startup log line and adds a third pass that delivers SIGSYS to a grant worker. Its existing assertions are as they were.
  • CI names the system call when a filter kill fails a run: a step that prints the kernel's audit lines, on failure only.
  • CI runs the Gateway on arm64 Linux: a gateway-arm64 job runs the Gateway crate's tests and the runtime test on ubuntu-24.04-arm. The owner added this criterion to Grant workers confine themselves under the namespace sandbox #22 after the session's retro.
  • docs/adr/ is left out of the handbook build, like docs/specs/ and docs/agents/. The strict build failed on ADR 0001, a page outside the navigation.

Left for #23 Operators can choose the filter sandbox: the startup error still reads Gateway worker sandbox failed to start (...). When the allow-list kills the startup probe, that message carries the signal and no layer name. #23 owns the error that names the sandbox and the layer.

The untracked folder crates/countersign-gateway/prototype-isolation-probe/ (a stray Cargo.lock) was in the worktree before this work and is not part of it.

From the session's retro, as the owner answered:

Extras for the owner

Evidence

Criterion Ticked Shown by
The worker sandbox module is public in the Gateway library, with one confine operation that reports the applied layers or names the layer that failed yes A confined grant worker reports its layers; A layer the host refuses fails confinement by name
Every grant worker, including the startup probe's worker, confines itself before reading any input yes The grant worker is confined before it is sent anything; runtime.py startup log
Startup logs the worker sandbox and each layer applied, including the Landlock ABI version or "Landlock unavailable" yes runtime.py startup log; Without Landlock it says so and is still confined
A new Rust integration test confines two concurrent stand-in grant workers ... yes Containment, two stand-ins; cargo test --workspace --locked
The allow-list rejects a foreign architecture, and the x32 range on x86-64 yes cargo test --workspace --locked in CI on x86-64
A grant worker killed by SIGSYS is logged as killed by the filter, and its grant is fenced and needs fresh approval yes runtime.py filter kill
The existing runtime test passes unchanged under the namespace sandbox in CI yes python crates/countersign-gateway/tests/runtime.py target/debug/countersign-gateway in CI
ADR 0001 and GLOSSARY.md are merged with this change yes git diff --stat origin/main...HEAD
CI runs the Gateway crate's tests, the worker sandbox containment test among them, and the runtime test on arm64 Linux yes The gateway-arm64 job, run 44662603958
A host that refuses Landlock's version query with EPERM is reported as Landlock unavailable, and the grant worker is still confined yes A host that denies Landlock is reported as without it and still confined
Test Red Green
Containment, two stand-ins (tests/worker_sandbox.rs: stream and threads, file, supervisor's environment, TCP, UDP, running a program, signalling another process, signalling itself, SIGSYS) With allow_list() not called: udp 54904: expected a refusal, got GotThrough; signal 0 9: expected a refusal, got Killed(9); trace-me: expected death by SIGSYS, got GotThrough ok
An unconfined process cannot read a grant worker's memory With PR_SET_DUMPABLE not set: left: GotThrough, right: Errno(1) ok
The grant worker is confined before it is sent anything With a read of the control socket placed before confine(): the grant worker waited for input unconfined ok
Without Landlock it says so and is still confined With ENOSYS no longer mapped to unavailable: the stand-in never served its stream ok
A layer the host refuses fails confinement by name With the Landlock error labelled as the allow-list: left: "seccomp allow-list: Operation not permitted (os error 1)" ok
A host that denies Landlock is reported as without it and still confined Before EPERM counted as unavailable: Landlock: Operation not permitted (os error 1), the stand-in never served its stream ok
Its threads work, and the grant worker starts, on a host without clone3 Without the clone rule: the probed grant worker ended with signal: 31 (SIGSYS) ok
Starting another process is refused Before the clone rule, on the host without clone3: the stand-in never served its stream ok
Having the kernel signal another process is refused With fcntl unrestricted: signal-on-io 723768: expected a refusal, got GotThrough ok
Returning from a signal handler works Without rt_sigreturn: left: Killed(31), right: GotThrough ok
runtime.py startup log With the startup eprintln! removed: AssertionError: [] ok
runtime.py filter kill (logged, fenced, Bob unaffected, a fresh approval served) With bubblewrap's exit code 159 not recognised: log has grant worker ended (exit status: 159), then AssertionError at the wait for the filter-kill line ok

Not shown red on its own: the x32 check (an allow-list kills an x32 number with or without the explicit range check), and the two memory-read checks with only the allow-list removed (non-dumpable memory still refuses them; the unconfined controls show the reads get through with no worker sandbox).

At commit 9fb3b25, the head, which adds the Landlock EPERM widening: cargo test --locked -p countersign-gateway locally on aarch64 gives worker_sandbox: 22 passed, 0 failed, and the same binary gives 22 of 22 in docker run ubuntu:24.04 under Docker's default profile. A fresh criteria judge read the widening's diff and called the criterion met, with no path that treats a Landlock failure after the version query as unavailable. No review round read this commit: three had run.

At commit 4f3ab9f: the gateway-arm64 job of run 44662603958 (ubuntu-24.04-arm) passed cargo test --locked -p countersign-gateway and the runtime test, and its x86-64 job passed too. At 69e7cff the same job printed worker_sandbox: 21 passed, 0 failed, then sidecar Gateway mTLS passed, shared Gateway mTLS passed, filter-killed grant worker fenced, so the runtime test does not flake on CI's arm64 as it does on the local machine. The Documentation workflow (mkdocs build --strict) failed at 69e7cff on ADR 0001 outside the navigation and passes at 4f3ab9f (run 44662603962). The new job was not shown red: a CI job has nothing to break but its own steps.

At commit e685181, whose Rust and Python files the head leaves unchanged:

  • cargo test --workspace --locked in CI (run 44655780164, ubuntu-latest, x86-64): pass. worker_sandbox: 23 passed, 0 failed, with a_system_call_in_the_x32_range_kills_it and a_system_call_from_a_foreign_architecture_kills_it both run, not skipped. Windows job: pass.
  • python crates/countersign-gateway/tests/runtime.py target/debug/countersign-gateway in CI (run 44655780170, ubuntu-24.04, x86-64, the real Gateway under bubblewrap): sidecar Gateway mTLS passed, shared Gateway mTLS passed, filter-killed grant worker fenced. Log: Gateway worker sandbox "namespaces": namespaces, non-dumpable, Landlock ABI v7, seccomp allow-list and Gateway grant alice: grant worker killed by the worker sandbox's filter (SIGSYS); grant fenced.
  • cargo test --locked -p countersign-gateway, local, aarch64, kernel 6.17: unit 3 and 4, sidecar 5, upstream 1, worker_sandbox 21 passed, 0 failed (the two x86-64 checks are compiled out). No skips.
  • The same worker_sandbox binary in docker run ubuntu:24.04 under Docker 29.2.1's default seccomp profile, aarch64: 21 passed, 0 failed. The first try there, on the build without the clone rule, was killed at clone (audit syscall=220), which is what round 1's finding 1 predicted.
  • The runtime test, local, aarch64: 1 of 4 runs passed. The other 3 failed at assert site.cutoff.wait(1) after Bob's retirement, which also fails 2 of 3 runs on main's code here (third extra above).
  • strace -D -f over the whole runtime test, local: exactly one killed by SIGSYS, the deliberate one.
  • Probe: bubblewrap 0.9.0 reports a child's fatal signal as exit code 128 plus the signal; bwrap ... sh -c 'kill -SYS $$' exits 159. Recorded beside killed_by_filter.
  • cargo +stable fmt --all -- --check and cargo +stable clippy --workspace --all-targets --locked -- -D warnings: clean.

Not run: Fargate (kernel 6.1, Landlock ABI v2), which is #24 Qualify the filter sandbox on Fargate with a maintained harness; the foreign-architecture check on arm64, where a 64-bit process cannot make a 32-bit call.

Merge Danger

Door: two-way. A revert removes the base layers; nothing stored changes.

Blast Radius: every grant worker, on every deployment.

The merge changes the Gateway executable and so its image; no configuration or infrastructure changes, and there is no flag. From this merge a system call a grant worker newly needs, from a dependency or C library update, kills grant workers until it is added to the allow-list. The startup probe, the runtime test and the containment test are what catch that first.

Reviews

Correctness, Standards, Spec and Security, three rounds (pinned c83a7e3, e685181, then 8b57275): 31 findings, each with its outcome

Correctness, round 1

  1. clone3 is allowed but not clone, so on a host that answers clone3 with ENOSYS the first thread kills the grant worker. Fixed: clone is allowed with CLONE_THREAD.
  2. The startup probe never exercises a thread or the async runtime. Fixed: it reports from a thread that builds the runtime.
  3. rt_sigreturn is missing, so returning from a signal handler is a filter kill. Fixed.
  4. Only ENOSYS and EOPNOTSUPP count as Landlock unavailable; EPERM from a container profile fails startup. Fixed: EPERM on the version query counts as unavailable.
  5. The worker-end log lines carry no identity. Fixed: they name the grant.
  6. The foreign-architecture, file and memory checks depend on the host. Fixed: no i386 entry point, Yama scope 2 and above, and /etc/hostname are each handled.
  7. A blocking recv hangs the test if the grant worker dies before reporting. Fixed: a read timeout.
  8. launch keeps an exited flag beside two channels for one fact. Fixed: the flag is gone.
  9. The one-byte report is encoded and decoded in two functions. Fixed: report and reported, side by side.
  10. The startup log hard-codes "namespaces". Pushed back: the worker sandbox choice and its type arrive with Operators can choose the filter sandbox #23 Operators can choose the filter sandbox.

Standards, round 1

  1. Same as 4. Fixed: as 4.
  2. The startup error names neither the sandbox nor the guide. Pushed back: that error is a criterion of Operators can choose the filter sandbox #23 Operators can choose the filter sandbox.
  3. New locals name the grant worker child, a word the glossary avoids. Fixed: process, in the lines this change adds.
  4. Layer::NoNewPrivs is not one of the ADR's base layers. Fixed: removed; the failure is reported under the allow-list.
  5. Same as 9. Fixed.
  6. Same as 10. Pushed back: as 10.
  7. start returns a bare tuple. Pushed back: a private function with two callers; the lifecycle state it sat beside is reduced by 8.
  8. Unclear names in the test (host, done, answer). Fixed: setup, checked, fail_with.
  9. Two drop guards with the same body in the test. Fixed: one Reaped.
  10. The CI step is copied into two workflows. Pushed back: two three-line steps; sharing them takes a composite action.

Spec, round 1

  1. The layer order differs from the ticket, with a fourth layer name. Fixed: three layer names; the order stays, since the kernel requires it, and the Summary says so.
  2. Every worker exit is now fenced and logged, not only SIGSYS. Pushed back: the watcher has to exist to see SIGSYS, a worker that ended was already fenced at its next connection, and the second line is what tells a crash from a filter kill.
  3. The CI steps were not asked for. Pushed back: they run on failure only and name the system call, which the spec's story 33 needs to be acted on.

Security, round 1

No finding at reportable confidence. Below it, and fixed here: fcntl was unrestricted, so F_SETOWN could have the kernel signal another process. Fixed: three commands only.

Correctness, round 2

No findings.

Standards, round 2

  1. When the allow-list kills the startup probe, the startup error names no layer. Pushed back: Operators can choose the filter sandbox #23 Operators can choose the filter sandbox owns that error; the Summary names this case for it.

Spec, round 2

  1. The exited guard in attach was removed. Pushed back: it answers finding 8; a send to a grant worker that ended fails and fences on the spot, and the watcher fences when it ends.
  2. clone3 stays unconditional, so a new process is refused only through clone. Carried over to The allow-list tells a thread from a new process under clone3 #28 The allow-list tells a thread from a new process under clone3

Security, round 2

No finding at reportable confidence. Below it: the clone3 point of finding 26, and that the clone rule would pass CLONE_THREAD with a namespace flag, which needs a capability no grant worker has.

Correctness, round 3 (the widening; Standards and Spec found nothing, and Spec judged the added criterion met)

  1. The failure step's audit lines mix the containment test's deliberate kills with a real one. Pushed back: each line carries its time and process, and the step runs only when the job failed.
  2. The job's comment said x86-64 runs both tests "below". Fixed: it says where each runs.
  3. The bubblewrap probe and the runtime step are copied from the x86-64 job. Pushed back: sharing them takes a composite action, for two jobs.
  4. The job installed the demo Integrator's whole fixture list. Fixed: cryptography alone.
  5. The runtime test relied on cargo test having built the Gateway. Fixed: an explicit build step.

The three round-3 fixes change the workflow only, in commit 4f3ab9f. No review round read them; the job's pass at that commit is their check.

Tracking

Epic: E1 Run grant workers in a filter sandbox on hosts without namespaces
Spec: #21 Run grant workers in a filter sandbox on hosts without namespaces
Ticket: #22 Grant workers confine themselves under the namespace sandbox
Flag: none

🤖 Generated with Claude Code

sodre and others added 4 commits November 19, 2026 19:31
ADR 0001 defines the equivalent OS sandbox the per-grant isolation
contract allows on hosts that cannot create namespaces, such as ECS
Fargate. GLOSSARY.md starts with the four terms it uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#22)

Every grant worker, the startup probe's included, now applies the base
layers of ADR 0001 to itself before it reads its control socket:
non-dumpable memory, Landlock with no rules granted, and a seccomp
allow-list whose default kills the process. Startup logs the worker
sandbox and each layer, and a grant worker that dies of SIGSYS is logged
as killed by the filter and its grant fenced.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…proval (#22)

The memory-read checks now opt out of Yama's descendant-only rule, so the
worker sandbox is what refuses them, and an unconfined reader checks
non-dumpable memory on its own. The Gateway's own grant worker is shown
confined before anything is sent to it. After a filter kill, a fresh
approval restores service.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…on needs (#22)

Review round 1. Docker's default profile answers clone3 with ENOSYS, so
the allow-list now lets clone start a thread and nothing else. fcntl is
down to the three commands a grant worker uses, which keeps F_SETOWN from
having the kernel signal another process. rt_sigreturn is allowed, so a
crash a handler sees first is not logged as a filter kill. The startup
probe reports from a thread with an async runtime, the worker-end log
lines name the grant, and a failed no_new_privs is reported under the
allow-list, the layer it belongs to.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
sodre and others added 4 commits November 19, 2026 21:32
The seccomp allow-list is written per architecture and CI ran only
x86-64. A new job runs the Gateway crate's tests, the containment test
among them, and the runtime test on ubuntu-24.04-arm.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The strict handbook build failed on docs/adr/0001, a page outside the
navigation. ADRs are maintainer records, read in the repository.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Round 3. It installs cryptography alone, builds the Gateway explicitly,
and its comment says where x86-64 runs each test.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A container profile older than Landlock answers its version query with
EPERM. ADR 0001 makes Landlock a backstop the Gateway starts without, so
that host is now reported as Landlock unavailable, as one with no
Landlock is. A failure after the kernel has named an ABI is still an error.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@sodre
sodre marked this pull request as ready for review November 20, 2026 03:00
@sodre
sodre merged commit ebbcba8 into main Nov 20, 2026
34 checks passed
sodre added a commit that referenced this pull request Nov 25, 2026
…x on hosts without namespaces is in git (#59)

Closes #21

## Summary

The text of the spec "Run grant workers in a filter sandbox on hosts
without namespaces" is in the repository at
`docs/specs/E1-21-run-grant-workers-in-a-filter-sandbox-on-hosts-without-names.md`,
as the issue held it when the spec closed. Nothing changes for anyone
using the product.

```text
docs/specs/
└── E1-21-run-grant-workers-in-a-filter-sandbox-on-hosts-without-names.md   # accepted, exported 2026-11-25
```

Before this closing, each of the spec's 41 user stories was mapped to
the test, static check or live run that proves it (the table under
Evidence). On `d5b15ba`, four stories (8, 9, 30 and 33) held but were
only partly tested: code broken on purpose still passed every test. #57
added their guards, building #56, a sub-issue of this spec that is now
done. One clause stays unmeasured: story 30's "so that throughput is
unchanged", which no seam in the spec's Testing Decisions measures and
#56 put out of scope.

The verification also filed #58, a flaky Electron GPU crash in the
Companion end-to-end run, with no milestone, so it does not hold this
spec open. It also ticked #24's last criterion, which asked for a
comment on #18; that is moot, because the reporter qualified and #18 is
closed.

## Evidence

| Criterion | Ticked | Shown by |
|---|---|---|
| Every sub-issue of #21 is closed | yes | `export-spec.py 21` |
| No issue but the spec is open in E1 | yes | `export-spec.py 21` |
| The spec has no release flag | yes | The spec's Further Notes:
"**Flag: none.**" |
| The file's text after its header is the issue's body | yes |
`same-as-issue.py` |
| Every user story is proven by a test, a static check or a live run |
yes | The user-story table below |

No test or guard is new here: the four guards #57 added were each shown
red there against code broken on purpose, and green against the real
code.

`python3 .claude/plugins/foresight/scripts/export-spec.py 21`, run after
#57 merged: `wrote … as accepted: every sub-issue is closed and only
specs are open in E1 Run grant workers in a filter sandbox on hosts
without namespaces, so the pull request that adds this file closes #21`.
The sub-issues are #22, #23, #24, #25 and #56, all closed. A comparison
of the file's text after its header with `gh issue view 21 --json body`,
CRLF read as LF: `#21: 18201 bytes after the header, 18201 in the
issue's body, the same`.

<details>
<summary>The 41 user stories of #21: 28 Test, 8 Static, 7 Live run
(stories 10 and 11 are both Test and Live run), 0 Partial, 0
Gap</summary>

Unless a row says otherwise, "CI" means the run at `d5b15ba`: [Sidecar
mTLS
45512063905](https://github.com/zeroae/countersign/actions/runs/45512063905)
(jobs `curl`, `gateway-arm64`, `gateway-filter-sandbox` on x86-64 and
arm64) and [CI
45512063655](https://github.com/zeroae/countersign/actions/runs/45512063655)
(`workspace`). All of them passed. `worker_sandbox.rs` is
`crates/countersign-gateway/tests/worker_sandbox.rs`, the containment
test (seam 2). `runtime.py` is
`crates/countersign-gateway/tests/runtime.py`, the real Gateway end to
end (seam 1). The script is `scripts/filter-sandbox-container.sh`.

| # | Story (shortened) | Verdict | Proved by | Notes |
|---|---|---|---|---|
| 1 | On Fargate, `"filter"` lets the Gateway start | Live run | The
harness run on Fargate 1.4.0, x86-64 and arm64 ([#24
comment](#24 (comment))):
`== Qualified`. The reporter's run on x86-64 ([#18
comment](#18 (comment))).
| In CI, the `gateway-filter-sandbox` job runs the same under Docker's
default profile. |
| 2 | An unchanged configuration keeps the namespace sandbox | Test |
`runtime.py` without `--worker-sandbox` writes no `worker_sandbox` field
and asserts the startup line `Gateway worker sandbox "namespaces":
namespaces, non-dumpable, Landlock …, seccomp allow-list`. CI `curl`,
`gateway-arm64`. | |
| 3 | An unknown value fails loading | Test | `runtime.py`
`configuration_loading`: `for value in ('seccomp', 'Filter', 'none', '',
None, True, ['filter']): assert not loads(worker_sandbox=value)` | |
| 4 | The Gateway never switches sandboxes | Test | Script steps 4 and 5
through `runtime.py` `startup_failure`: `assert result.returncode != 0,
'The Gateway started under a worker sandbox this host was expected to
refuse'`. Step 4 runs `"namespaces"` where namespaces are refused; step
5 runs `"filter"` where the allow-list is refused, in an image that has
bubblewrap. | PR #34 showed it red: with `"namespaces"` routed to the
direct launch, the Gateway started (`TimeoutExpired`). |
| 5 | Startup probes a real grant worker and stops a broken sandbox |
Test | Script steps 4 and 5: the Gateway exits before it listens.
`worker_sandbox.rs`
`the_grant_worker_is_confined_before_it_is_sent_anything` runs the
Gateway's own grant worker and probes it. | Step 5 fails inside the
probe worker's own confinement, not in the supervisor. |
| 6 | The startup error names the sandbox and the failed layer | Test |
`startup_failure`: `re.fullmatch(rf'worker sandbox "{sandbox}" failed:
{re.escape(layer)}: \S.*', lines[0])`. CI logs `worker sandbox
"namespaces" failed: namespaces: bwrap: …` and `worker sandbox "filter"
failed: seccomp allow-list: …`. | Seam 1 drives layers `namespaces` and
`seccomp allow-list`. `Landlock` is named at seam 2 by
`a_layer_the_host_refuses_fails_confinement_by_name`. No test drives
`non-dumpable` or `launch`. |
| 7 | The error points to the operator guide, not to the other sandbox |
Test | `startup_failure`: `assert 'operate/#choose-a-worker-sandbox' in
lines[1]` and `assert f'"{other}"' not in result.stderr` | Nothing ties
the anchor in the Rust string (`runtime/worker.rs`) to the heading in
`docs/operate.md`. Renaming the heading would leave a dead link with
every check green. |
| 8 | Startup logs the sandbox, each layer, and the Landlock ABI or
"unavailable" | Test | `runtime.py`: `assert wait_for_log(… r'Landlock
(ABI v[1-9]\d*\|unavailable), seccomp allow-list')`. For "unavailable":
the script's step `== The filter sandbox starts on a kernel without
Landlock` runs `runtime.py --worker-sandbox filter --landlock
unavailable`, which pins the line to `Gateway worker sandbox "filter":
non-dumpable, Landlock unavailable, seccomp allow-list`. | Added by #57
(`ef3891e`), after `d5b15ba`. Every CI host has Landlock; the step
refuses `landlock_create_ruleset` with `ENOSYS`, using the script's
`refusing` profile. |
| 9 | The filter sandbox starts on a kernel without Landlock | Test |
The same script step: the real Gateway starts and passes every runtime
pass, filter kill included. Seam 2 as well:
`without_landlock_it_says_so_and_is_still_confined` and
`a_host_that_denies_landlock_is_reported_as_without_it_and_still_confined`.
| Added by #57 (`ef3891e`). It fails when the supervisor rejects a probe
that reports no Landlock: `worker sandbox "filter" failed: launch: the
probe grant worker reported no layers`. The real code passes. |
| 10 | Shared mode under the filter sandbox keeps users' grant workers
apart | Test, Live run | `runtime.py --worker-sandbox filter`, shared
pass, in `gateway-filter-sandbox`: three grant workers serve
concurrently, and `'Alice cutoff affected Bob'`, `"Alice's killed grant
worker affected Bob"`. Seam 2 refuses cross-worker memory reads and
signals (rows 21 and 24). Fargate: the harness's shared pass, and the
reporter's two concurrent grants. | |
| 11 | Sidecar mode works under the filter sandbox | Test, Live run |
`sidecar Gateway mTLS passed` under `"filter"` in
`gateway-filter-sandbox` (x86-64, arm64) and in the Fargate harness run.
| |
| 12 | The supervisor stays unprivileged in both sandboxes | Test | The
runs are not root. The script runs `docker run --user "$(id -u):$(id
-g)"` with no added capability. CI runs `runtime.py` under bubblewrap as
the runner's user, without `sudo`. The Fargate tasks logged `uid / gid:
65531 / 65531` with no capabilities. | Proven by where the tests run,
not by an assertion. A job that ran as root would stop guarding this
story. |
| 13 | The filter sandbox needs no `/usr/bin/bwrap` | Test | Script: `if
inside filter test -e /usr/bin/bwrap; then … exit 1`, then the runtime
test under `"filter"` in that image. `runtime.py` `launched_directly`
asserts that every grant worker's parent is the Gateway and that its
`Name:` is `countersign-gat`. | The Fargate image has no bubblewrap
either (`qualify.sh`). |
| 14 | The operator guide says the filter sandbox gives up the namespace
layer | Static | `docs/operate.md`, "Choose a worker sandbox": "The
filter sandbox gives up the namespace layer: a grant worker shares the
supervisor's filesystem, process table and network stack …" | Read at
`d5b15ba`. `mkdocs build --strict` guards the anchor only, not the
wording. |
| 15 | The configuration reference describes `worker_sandbox` and both
values | Static | `docs/reference/config.md`, the `worker_sandbox` row:
default `"namespaces"`, both values, "Any other value fails loading". |
Read at `d5b15ba`. |
| 16 | The troubleshooting table covers a startup failure under either
sandbox | Static | `docs/operate.md`, the row "Gateway exits with
`worker sandbox "<sandbox>" failed: …`", under `"namespaces"`,
`"filter"` and either. | Read at `d5b15ba`. |
| 17 | The log says when the filter killed a grant worker | Test |
`runtime.py` filter-kill pass, under both sandboxes:
`wait_for_log(r"Gateway grant alice: grant worker killed by the worker
sandbox's filter \(SIGSYS\); grant fenced")` | The test sends `SIGSYS`
itself, since the supervisor cannot tell that from a filter kill. Seam 2
shows that the filter's kill is `SIGSYS` (row 25). PR #26 showed it red
under bubblewrap's exit code 159. |
| 18 | A grant whose worker the filter killed needs fresh approval |
Test | `assert request('alice').returncode != 0, 'A grant whose worker
the filter killed was served again'`, then `'A fresh approval did not
restore service'` with a new grant | |
| 19 | A grant worker cannot open any file | Test |
`opening_a_file_is_refused` (`open /`, unconfined control gets through)
| Both stand-ins, each in turn. |
| 20 | A grant worker cannot read the supervisor's environment or memory
| Test | `reading_the_supervisors_environment_is_refused` (`open
/proc/<supervisor>/environ`) and
`reading_the_supervisors_memory_is_refused` (`process_vm_readv`) | The
unit test
`filter_sandbox_launch_passes_on_no_descriptor_and_no_environment` shows
the launch passes on no environment. |
| 21 | A grant worker cannot read another grant worker's memory | Test |
`reading_the_other_grant_workers_memory_is_refused`, and
`an_unconfined_process_cannot_read_a_grant_workers_memory`:
`Outcome::Errno(libc::EPERM)` | The unconfined control runs where Yama
allows it (scope 0 or 1, as on Fargate). |
| 22 | A grant worker cannot open TCP connections or send UDP datagrams
| Test | `a_tcp_connection_is_refused`, `a_udp_datagram_is_refused`
(each with an unconfined control that gets through) | |
| 23 | A grant worker cannot run programs | Test |
`running_a_program_is_refused` (`execv /bin/true`), plus
`starting_another_process_is_refused` (`fork`) and
`starting_another_process_by_clone3_fails_as_unsupported` | |
| 24 | A grant worker can signal only itself | Test |
`signalling_another_process_is_refused`: `kill` to the other stand-in,
the supervisor and its own process group.
`having_the_kernel_signal_another_process_is_refused` (`F_SETOWN`).
`signalling_itself_works`: `Outcome::Killed(libc::SIGTERM)` on itself,
with the other unharmed. | `tgkill` to another process is not tried.
`tkill` and `pidfd_send_signal` are covered only by the general kill of
off-list calls (row 25). |
| 25 | A forbidden system call kills the grant worker | Test |
`a_forbidden_system_call_kills_it_with_sigsys`: `*o ==
Outcome::Killed(libc::SIGSYS)` for `ptrace(PTRACE_TRACEME)` | |
| 26 | The allow-list rejects a foreign ABI (x32, the wrong
architecture) | Test | `a_system_call_in_the_x32_range_kills_it` and
`a_system_call_from_a_foreign_architecture_kills_it` (`int 0x80`) ran,
not skipped, in `workspace (ubuntu-latest)`, `gateway-filter-sandbox
(ubuntu-24.04)` and on Fargate x86-64. | x86-64 only. On arm64 a 64-bit
process has no 32-bit entry point to call, so the architecture check
there runs in no test. The x32 test would pass without the explicit x32
range check, since the allow-list kills the number anyway (PR #26). |
| 27 | ADR 0001 defines an equivalent OS sandbox | Static |
`docs/adr/0001-filter-sandbox-for-hosts-without-namespaces.md`, `status:
accepted`: "define it as the equivalent OS sandbox for hosts that cannot
create namespaces", with the base layers in decision 1 | Read at
`d5b15ba`. |
| 28 | The namespace sandbox has the same base layers | Test |
`runtime.py` default sandbox asserts `"namespaces": namespaces,
non-dumpable, Landlock …, seccomp allow-list`, which the probe worker
reports from inside bubblewrap. CI `curl`, `gateway-arm64`. | |
| 29 | A grant worker still receives its streams by `SCM_RIGHTS` after
confinement | Test | Every stand-in in `worker_sandbox.rs` takes its
stream by `recvmsg` after `confine()`: `assert_eq!(words[0], "ready",
"the stand-in never served its stream")`. Every `runtime.py` request
passes three streams to a confined grant worker (`ChildHandle::attach`).
| |
| 30 | A grant worker still serves concurrent connections on threads |
Test | `runtime.py`: two requests by one user, so to one grant worker,
held at the site's `/together` barrier until both arrive: `assert
all(res.returncode == 0 for res in both)`. Every pass, both sandboxes. |
Added by #57 (`ef3891e`). It fails when the grant worker serves one
connection at a time (`curl: (56)`, `curl: (35)`). "Throughput is
unchanged" is not measured: Testing Decisions names no seam that could
measure it. |
| 31 | CI runs the real Gateway under the filter sandbox in a container
that refuses namespaces | Static | CI job `gateway-filter-sandbox`
(x86-64, arm64). The script fails when the container can create
namespaces: `'This container can create namespaces, so it proves nothing
about the filter sandbox.'` | |
| 32 | CI keeps running the real Gateway under the namespace sandbox |
Static | CI jobs `curl` (x86-64) and `gateway-arm64` run `runtime.py`
with the default sandbox and log `Gateway worker sandbox "namespaces":
namespaces, …`. | |
| 33 | A missing system call fails CI | Test | Any filter kill fails
`runtime.py` or the startup probe; PR #26 showed it red without the
`clone` rule. For the lazy path that Further Notes names,
`worker_sandbox.rs` `a_panic_unwinds_and_the_grant_worker_lives_on` has
each stand-in's first panic unwind after confinement, and expects a
reply. | Added by #57 (`ef3891e`). With `write` removed from the
allow-list (a panic writes its message), it fails with ``stand-in 0,
`panic`: expected a reply, got Killed(31)``. This still guards only the
paths the tests drive. |
| 34 | The containment checks run against the worker sandbox's own
interface | Test | `worker_sandbox.rs`: `use
countersign_gateway::worker_sandbox::confine;`. Each stand-in calls
`confine()`, and each property has its own named test. | |
| 35 | The containment checks run with two concurrent stand-ins | Test |
`each_of_two` starts two stand-ins, aims each attempt at the other, and
asserts `"stand-in {attacker}'s `{command}` harmed the other stand-in"`
after each. | |
| 36 | The glossary defines grant worker, worker sandbox, namespace
sandbox and filter sandbox | Static | `GLOSSARY.md`, "Gateway
isolation": all four terms | Read at `d5b15ba`. |
| 37 | The reporter qualifies the filter sandbox on real Fargate with
two concurrent grants | Live run | [#18
comment](#18 (comment)):
Fargate 1.4.0 x86-64, v0.2.1, `worker_sandbox: "filter"`. Two grants
held open at the site's barrier, 1.398 s apart. | x86-64 only. The
tested-platforms page lists arm64 as "Harness only". |
| 38 | Fargate passes the same end-to-end check as Compose | Live run |
The same run: a paired Companion approved the demo identity for each
grant, and both chat replies showed the site's flag, with hashes matched
at the site. | |
| 39 | The design record's platform line names both worker sandboxes |
Static | `docs/specs/2026-11-17-countersign-design.md`: "one of two
worker sandboxes, chosen by the operator: the namespace sandbox … or the
filter sandbox …" | Read at `d5b15ba`. |
| 40 | Both seams run on real Fargate, x86-64 and arm64, from a harness
in the repo | Live run | `qualification/fargate/`. Its run at `30bedc2`
([#24
comment](#24 (comment))):
containment test 25/0 on x86-64 and 23/0 on arm64, runtime test passed
on both, kernel 6.1.190, Landlock ABI v2. | Between `30bedc2` and
`d5b15ba`, `worker_sandbox.rs` and `runtime/worker.rs` are unchanged,
`runtime/mod.rs` changes only on the supervisor's side, and `Cargo.lock`
changes only versions. |
| 41 | The harness can be rerun for any later release that touches the
grant worker | Live run | `qualification/fargate/run.sh local` at
`d5b15ba`, in this verification (arm64, Docker's default profile): exit
0, containment 23/0, every `runtime.py` pass including the egress-proxy
ones, `== Qualified`. `docs/develop.md`: "Run it for every release that
touches the grant worker." | Run locally, not on Fargate. No Fargate run
is due: the grant worker has not changed since `30bedc2` (row 40). |

</details>

Not run: nothing. `mkdocs.yml` excludes `/specs/` from the site, so no
documentation build reads the file.

## Merge Danger

**Door:** two-way. A revert removes the file, and #21 is reopened by
hand.

**Blast Radius:** none.

The merge ships no image, release or infrastructure, and no flag.

## Reviews

<details>
<summary>No review ran: the file is the issue's text, checked byte for
byte</summary>

</details>

## Tracking

Epic: E1 Run grant workers in a filter sandbox on hosts without
namespaces
Spec: #21 Run grant workers in a filter sandbox on hosts without
namespaces
Ticket: none
Flag: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grant workers confine themselves under the namespace sandbox

1 participant