Skip to content

feat(gateway): An operator can run the Gateway under the filter sandbox where namespaces are refused - #34

Merged
sodre merged 4 commits into
mainfrom
feat/23-worker-sandbox-filter
Nov 20, 2026
Merged

sodre merged 4 commits into
mainfrom
feat/23-worker-sandbox-filter

Conversation

@sodre

@sodre sodre commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Closes #23

Summary

An operator on a host that refuses namespaces, such as ECS Fargate, can set worker_sandbox to "filter" in the Gateway configuration, and the Gateway starts and serves grants there without bubblewrap. With the field left out nothing changes: the namespace sandbox stays the default, the Gateway never switches from one sandbox to the other, and a sandbox that cannot start stops the Gateway with worker sandbox "<sandbox>" failed: <layer>: <cause>.

countersign-gateway serve gateway.json
  Config::load                      # worker_sandbox: "namespaces" (default) | "filter"; anything else fails
  ChildHandle::verify_environment   # probes a real grant worker under the chosen sandbox
    launch_command
      "namespaces" -> bwrap ... /worker grant-worker     # as before
      "filter"     -> <the Gateway executable> grant-worker
                        cleared environment
                        parent-death signal               # what --die-with-parent gave
                        every descriptor above 2 close-on-exec
    grant worker: confine()         # the base layers, the same under both
  on failure: exit 1
    worker sandbox "<sandbox>" failed: <layer>: <cause>
    See "Choose a worker sandbox" in the operator guide: <link>

<layer> is non-dumpable, Landlock or seccomp allow-list when a base layer failed, namespaces when bubblewrap or its namespaces did, and launch when the filter sandbox could not start the grant worker at all.

Choices the ticket left open:

  • A grant worker does not outlive its supervisor under "filter". bubblewrap's --die-with-parent gave this under the namespace sandbox. Started directly, a grant worker would wait forever on its control socket after the supervisor was killed, holding a grant's traffic keys. The launch sets a parent-death signal, and the runtime test now asserts it under both sandboxes.
  • How the failed layer reaches the supervisor. A grant worker that cannot apply a base layer exits with status 64, 65 or 66 (non-dumpable, Landlock, allow-list) and writes the cause to standard error. bubblewrap passes the status on. Reading the layer out of the error text broke as soon as a warning came first.
  • No kernel floor beyond the base layers'. Marking every descriptor close-on-exec in one call needs Linux 5.11. Where the kernel or an older container profile refuses that call, the launch lists /proc/self/fd itself between fork and exec and marks each one, and fails when it cannot. Spec story 9 asks that older kernels are not locked out.
  • launch as a layer name. ADR 0001's layers cannot name a failure to start the process, and the error's form needs one. The operator guide defines it where the operator reads it.
  • The CI job is a script, scripts/filter-sandbox-container.sh, so a maintainer can run the same thing locally. It builds on the host and runs in ubuntu:24.04 as an unprivileged user. Two images: one without bubblewrap (the filter sandbox does not need it), one with (the namespace sandbox fails there because the host refuses namespaces, not because a program is missing). Two last steps leave Docker's default profile for one quirk each: a host that refuses the allow-list, and a kernel without close_range.
  • The job runs on x86-64 and arm64, because the allow-list is written per architecture.

Extras for the owner

  • The runtime test's cutoff assertion after Bob's retirement fails intermittently, on main too. assert site.cutoff.wait(1) in the shared-mode retirement part of crates/countersign-gateway/tests/runtime.py failed 2 of 6 runs of main's test against main's binary on this arm64 host, and at a similar rate on this branch under both sandboxes. It predates this ticket and nothing here touches it. No source settles it.

Evidence

Criterion Ticked Shown by
The configuration accepts optional worker_sandbox, "namespaces" (default) and "filter"; any other value fails loading yes The configuration loads only the two values
Under "filter", grant workers start without bubblewrap and without /usr/bin/bwrap, in sidecar and shared mode yes Filter grant workers are started by the Gateway itself; scripts/filter-sandbox-container.sh step 3, in an image with no bubblewrap
There is no automatic fallback in either direction yes The namespace sandbox refuses to start where namespaces are refused; The filter sandbox refuses to start where the allow-list is refused
A startup failure exits non-zero, names the sandbox and the failed layer, points to the operator guide, and does not suggest the other sandbox yes The same two tests, which read the exit status and both lines of the error
A new CI job, in a container under Docker's default profile, runs the runtime test under "filter" (sidecar, shared, concurrent users, cutoff, revocation) yes The job gateway-filter-sandbox on 36d2eda, x86-64 and arm64 runners (https://github.com/zeroae/countersign/actions/runs/44679962288): sidecar Gateway mTLS passed, shared Gateway mTLS passed, filter-killed grant worker fenced under Gateway worker sandbox "filter"
The same job runs the worker sandbox containment test yes The same job: 25 passed, 0 failed on x86-64, 23 passed, 0 failed on arm64
The same job proves that "namespaces" fails at startup there with the named error yes The same job: worker sandbox "namespaces" failed: namespaces: bwrap: No permissions to create new namespace, ..., sidecar and shared
The configuration reference documents worker_sandbox and both values yes mkdocs build --strict, which resolves the row's link to the new section
The operator guide has a section on choosing a worker sandbox yes mkdocs build --strict; the startup error's link ends in the section's anchor, operate/#choose-a-worker-sandbox, which the startup tests assert
The troubleshooting row covers both sandboxes yes mkdocs build --strict, which resolves the row's link
The design record's platform line names both worker sandboxes yes git diff origin/main...HEAD -- docs/specs/2026-11-17-countersign-design.md: one line, naming the namespace sandbox and the filter sandbox
Test Red Green
The configuration loads only the two values (runtime.py, configuration_loading) Before the field existed: AssertionError: namespaces ok
Filter grant workers are started by the Gateway itself (runtime.py, launched_directly) With "filter" routed through bubblewrap: AssertionError: Name: bwrap ok
The namespace sandbox refuses to start where namespaces are refused (--worker-sandbox namespaces --startup-fails namespaces, script step 4) With try "filter" added to the message: AssertionError; with "namespaces" routed to the direct launch, a fallback: the Gateway started, TimeoutExpired ok
The filter sandbox refuses to start where the allow-list is refused (--worker-sandbox filter --startup-fails 'seccomp allow-list', script step 5, image with bubblewrap) Under the default profile, where the filter sandbox works: the Gateway started, TimeoutExpired, exit 1. With the exit-status mapping shifted by one: worker sandbox "filter" failed: Landlock: ..., AssertionError ok
No grant worker outlives its supervisor (runtime.py, after the filter-kill scenario) Without the parent-death signal: AssertionError: A grant worker outlived its supervisor ok
The filter sandbox's launch passes on no descriptor and no environment (unit test filter_sandbox_launch_passes_on_no_descriptor_and_no_environment) With close_range starting at 1,000,000: FAILED; with env_clear removed: FAILED ok
The same test where close_range is refused (script step 6) With the listing marking nothing: FAILED, exit 101 ok

What else ran, on an arm64 host (Linux 6.17, Docker 29.2.1, bubblewrap 0.9.0), at 36d2eda:

  • scripts/filter-sandbox-container.sh: exit 0, six steps. The container refuses namespaces (bwrap: No permissions to create new namespace). Containment test: 23 passed, 0 failed. Runtime test under "filter": sidecar Gateway mTLS passed, shared Gateway mTLS passed, filter-killed grant worker fenced, with the log Gateway worker sandbox "filter": non-dumpable, Landlock ABI v7, seccomp allow-list. Step 4 printed worker sandbox "namespaces" failed: namespaces: bwrap: No permissions to create new namespace, ...; step 5 printed worker sandbox "filter" failed: seccomp allow-list: Invalid argument (os error 22); each followed by See "Choose a worker sandbox" in the operator guide: https://zeroae.github.io/countersign/operate/#choose-a-worker-sandbox.

  • runtime.py target/debug/countersign-gateway, with no option and with --worker-sandbox filter, on the host: all three lines each. Each needed retries for the flake under Extras.

  • cargo test --locked -p countersign-gateway: 14 unit and integration tests passed and the containment test's 23, 0 ignored, 0 failed.

  • cargo fmt --all -- --check, cargo clippy --locked -p countersign-gateway --all-targets -- -D warnings, mkdocs build --strict: clean.

  • Probe (2026-11-19): on main, runtime.py with main's binary, six runs: four passed, two failed at assert site.cutoff.wait(1).

  • GitHub, on 36d2eda: all 28 checks passed. The job gateway-filter-sandbox ran all six steps of the script on x86-64 and arm64 runners, and the workspace jobs ran cargo test --workspace, pnpm lint and pnpm test.

Not run: nothing

Merge Danger

Door: two-way. A revert removes the field; a configuration that sets worker_sandbox then fails to load as an unknown field, so an operator who set it removes it first. No release carries the field yet.

Blast Radius: Gateway startup and grant worker launch.

The merge ships no image and no infrastructure. It adds one CI job to the end-to-end workflow. For a Gateway that leaves worker_sandbox out, two things change at the next release: a failed startup probe prints worker sandbox "namespaces" failed: namespaces: <cause> in place of Gateway worker sandbox failed to start (...), and a grant worker that cannot apply a base layer exits with 64, 65 or 66 in place of 1. No flag.

Reviews

Correctness, Standards, Spec and Security, three rounds: 24 findings, each with its outcome. Round 3 found nothing.

Pinned commits: round 1 7b85f451de2439a1ddf69de642118de9c93b9e80, round 2 11bed34dbeba058e81e5e6fef99615da8a59af6a, round 3 36d2edaa9166242fa5142f244f0b08b93b3f6a33. Security found nothing in any round.

Correctness, round 1

  1. The failed layer was read out of the probe's standard error by its prefix, so a warning ahead of it blamed the wrong layer. Fixed: the grant worker's exit status carries the layer.
  2. The direct launch has no counterpart to bubblewrap's --cap-drop ALL, --new-session and --chdir /. Pushed back: the allow-list leaves a confined grant worker no system call that a capability, a session or a working directory changes (signals only to itself, no file or socket call, ioctl only for FIONBIO), it confines itself before reading any input, and the operator guide keeps the supervisor unprivileged.
  3. A failed launch reached the operator as a bare error number, hiding the Linux 5.11 requirement. Fixed: the requirement is gone; the launch marks descriptors one by one where the kernel refuses the single call.
  4. The test's check that the other sandbox is not named matched the bare word, which the allow-list's own failure text contains. Fixed: it looks for the quoted value, and the text says "the allow-list killed".
  5. The script assumed cargo's target directory is ./target. Fixed: it takes each executable's path and the target directory from cargo, and mounts the directory.
  6. The filter-fails step depended on the host kernel offering Landlock. Fixed: the step refuses the allow-list's own call, which every kernel reaches.
  7. The new unit test depended on HOME being set and standard input being open. Fixed: it duplicates a descriptor it opened, and reads the launched environment with env.
  8. Option parsing unpacked before the assertion that prints the usage. Fixed.
  9. The sandbox's names lived in several hand-kept places. Fixed: WorkerSandbox::outer_layer serves the startup log and the error.

Standards, round 1

  1. The developer guide's new paragraph split the SIGSYS section's text. Fixed: it moved under "Run the checks".
  2. A test comment called grant workers "its child", which the glossary avoids. Fixed.
  3. launch is a layer that neither ADR 0001 nor the glossary defines. Pushed back: the error's form needs a layer for a grant worker that could not be started at all, the ticket itself says the supervisor "launches each grant worker directly", and the operator guide defines the name beside the others.
  4. Possible Primitive Obsession: the probe's failure was a string re-parsed for its layer. Fixed: it is a layer and a cause.
  5. Possible Repeated Switches on the sandbox for the outer layer's name. Fixed, with 9.
  6. Possible Mysterious Name: sandbox(sandbox, ...) and direct. Fixed: launch_command, namespace_sandbox, filter_sandbox.
  7. Possible Duplicated Code: the script's last docker run repeated inside. Fixed: inside takes the profile.
  8. Possible Duplicated Code in configuration_loading. Fixed.
  9. Possible Divergent Change: do_test takes a third flag. Pushed back: the function held several scenarios behind flags before this ticket, and splitting the runtime test is not this ticket's work.

Spec, round 1

  1. The direct launch needed Linux 5.11, which neither the ticket nor the spec decided, against spec story 9. Fixed, with 3.
  2. Filter-sandbox grant workers are killed when the supervisor dies, which no criterion asks for. Pushed back: it keeps what --die-with-parent gave under the namespace sandbox; without it a grant worker holding traffic keys outlives a killed supervisor. Named in the Summary as a choice the ticket left open.

Correctness, round 2

  1. The script left its first temporary profile behind. Fixed: one file, removed on exit.

Standards, round 2

  1. A new comment called the grant worker bubblewrap's "child". Fixed.
  2. The developer guide and the script's header still described two tests under the default profile. Fixed: both say what the two last steps do.

Spec, round 2

  1. The fallback marked only descriptors listed before the fork, dropped fcntl's result, and said nothing. Fixed: the listing runs between fork and exec by system calls alone, and the launch fails when it cannot list or mark a descriptor.

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: #23 Operators can choose the filter sandbox
Flag: none

🤖 Generated with Claude Code

sodre and others added 4 commits November 19, 2026 23:55
The Gateway configuration takes an optional `worker_sandbox`: "namespaces"
(the default) or "filter". Under "filter" the supervisor starts each grant
worker itself, with no bubblewrap: a cleared environment, no descriptor
beyond the control socket and the standard streams, and a parent-death
signal in place of bubblewrap's --die-with-parent. The grant worker then
confines itself with the base layers, as under the namespace sandbox. The
Gateway never falls back from one sandbox to the other.

When the chosen sandbox cannot start, startup exits with
`worker sandbox "<sandbox>" failed: <layer>: <cause>` and a pointer to the
operator guide's new section on choosing a worker sandbox.

A new job, gateway-filter-sandbox, runs the containment test and the
runtime test under "filter" in a container under Docker's default security
profile, on x86-64 and arm64, and proves that "namespaces" fails at startup
there with the named error.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ap at hand (#23)

A container whose profile refuses one call of the Landlock layer: the
Gateway under "filter" exits with the named error and starts no grant
worker another way. The developer guide's line on the script moves to a
paragraph of its own.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…nels launch (#23)

- A grant worker that cannot apply a base layer exits with a status that
  names the layer, so the startup probe no longer reads it out of the
  standard error text, where a warning ahead of it hid it.
- The filter sandbox's launch no longer needs Linux 5.11: where the kernel
  or the container profile refuses close_range, the descriptors listed
  before the fork are marked close-on-exec one by one. The docs drop the
  kernel floor.
- The container script takes the executables' paths from cargo, mounts
  cargo's target directory, and gains two steps: the filter sandbox fails
  by name where the host refuses the allow-list, and passes on no
  descriptor where close_range is refused.
- The runtime test's --startup-fails takes the layer it expects, and looks
  for the other sandbox's quoted value, not the bare word.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…23)

Where close_range is refused, the grant worker's launch now lists the open
descriptors itself, between fork and exec, by system calls alone, and
fails when it cannot list or mark one. The listing no longer happens in
the supervisor ahead of the fork, where a descriptor opened in between
would have been missed.

The container script removes its temporary profile, and it and the
developer guide say what its two last steps do.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@sodre
sodre marked this pull request as ready for review November 20, 2026 05:36
@sodre
sodre merged commit f13433d into main Nov 20, 2026
38 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.

Operators can choose the filter sandbox

1 participant