diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f71566d..b00851c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,3 +32,6 @@ jobs: - run: cargo fmt --all -- --check - run: cargo clippy --workspace --all-targets --locked -- -D warnings - run: cargo test --workspace --locked + - name: Name the system call when the worker sandbox's filter killed a grant worker + if: failure() && runner.os == 'Linux' + run: sudo dmesg | grep 'type=1326' | tail -n 20 || true diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 6de9ba3..7c5c443 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -7,6 +7,32 @@ concurrency: permissions: contents: read jobs: + gateway-arm64: + # The seccomp allow-list is written per architecture. On x86-64 the + # containment test runs in ci.yml and the runtime test in the job below. + runs-on: ubuntu-24.04-arm + timeout-minutes: 30 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + - run: sudo apt-get update && sudo apt-get install -y apparmor-profiles bubblewrap libnss-wrapper + - name: Enable the distribution's bubblewrap profile when the host restricts user namespaces + run: | + if ! bwrap --unshare-all --cap-drop ALL --ro-bind /usr /usr --symlink usr/lib /lib --symlink usr/lib64 /lib64 -- /usr/bin/true; then + sudo apparmor_parser --replace /usr/share/apparmor/extra-profiles/bwrap-userns-restrict + bwrap --unshare-all --cap-drop ALL --ro-bind /usr /usr --symlink usr/lib /lib --symlink usr/lib64 /lib64 -- /usr/bin/true + fi + - uses: Swatinem/rust-cache@v2 + - run: pip install cryptography==50.0.2 + - run: cargo test --locked -p countersign-gateway + - run: cargo build --locked -p countersign-gateway + - name: Exercise shared and sidecar workers and lease cutoff + run: timeout 120 python crates/countersign-gateway/tests/runtime.py target/debug/countersign-gateway + - name: Name the system call when the worker sandbox's filter killed a grant worker + if: failure() + run: sudo dmesg | grep 'type=1326' | tail -n 20 || true curl: runs-on: ubuntu-24.04 timeout-minutes: 40 @@ -32,6 +58,9 @@ jobs: - run: cargo build --locked --workspace - name: Exercise shared and sidecar workers and lease cutoff run: timeout 120 python crates/countersign-gateway/tests/runtime.py target/debug/countersign-gateway + - name: Name the system call when the worker sandbox's filter killed a grant worker + if: failure() + run: sudo dmesg | grep 'type=1326' | tail -n 20 || true - run: node scripts/native-package.mjs debug - run: pnpm --filter @countersign/companion exec electron-builder --dir --publish never - name: Choose the last identity and compare it to the upstream TLS peer diff --git a/GLOSSARY.md b/GLOSSARY.md new file mode 100644 index 0000000..652a5a5 --- /dev/null +++ b/GLOSSARY.md @@ -0,0 +1,23 @@ +# Countersign + +Desktop approval for HTTPS Workloads that use an installed client certificate. The design record, `docs/specs/2026-11-17-countersign-design.md`, defines the rest of the language until it moves here. + +## Language + +### Gateway isolation + +**Grant worker**: +The short-lived, low-privilege process the Gateway supervisor starts for one grant version, which carries that grant's traffic and nothing else. +_Avoid_: worker process, child, sandbox + +**Worker sandbox**: +The OS isolation around every grant worker, chosen by the operator, that keeps it from the supervisor's credentials, other grant workers and the network. +_Avoid_: sandbox mode, isolation level + +**Namespace sandbox**: +The default worker sandbox: the filter sandbox's guarantees plus a separate view of the filesystem, processes and network for each grant worker. +_Avoid_: bubblewrap mode, bwrap sandbox + +**Filter sandbox**: +The worker sandbox for hosts that cannot give a grant worker its own namespaces, where the kernel refuses every action a grant worker does not need. +_Avoid_: seccomp mode, seccomp sandbox, fallback sandbox diff --git a/crates/countersign-gateway/Cargo.toml b/crates/countersign-gateway/Cargo.toml index 4387c77..5697c7c 100644 --- a/crates/countersign-gateway/Cargo.toml +++ b/crates/countersign-gateway/Cargo.toml @@ -46,3 +46,7 @@ aws-runtime = "1.10" aws-smithy-http-client = { version = "1.5", features = ["test-util"] } aws-smithy-types = "1" tempfile = "3" + +[[test]] +name = "worker_sandbox" +harness = false diff --git a/crates/countersign-gateway/prototype-isolation-probe/Cargo.lock b/crates/countersign-gateway/prototype-isolation-probe/Cargo.lock new file mode 100644 index 0000000..a10c581 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/Cargo.lock @@ -0,0 +1,16 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "isolation-probe" +version = "0.0.0" +dependencies = [ + "libc", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/.rustc_info.json b/crates/countersign-gateway/prototype-isolation-probe/target/.rustc_info.json new file mode 100644 index 0000000..2cd3714 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/.rustc_info.json @@ -0,0 +1 @@ +{"rustc_fingerprint":4815122195271935405,"outputs":{"7971740275564407648":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/sodre/.rustup/toolchains/1.99.0-aarch64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"aarch64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"neon\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_has_atomic_primitive_alignment=\"128\"\ntarget_has_atomic_primitive_alignment=\"16\"\ntarget_has_atomic_primitive_alignment=\"32\"\ntarget_has_atomic_primitive_alignment=\"64\"\ntarget_has_atomic_primitive_alignment=\"8\"\ntarget_has_atomic_primitive_alignment=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""},"11741312833096633296":{"success":true,"status":"","code":0,"stdout":"rustc 1.99.0 (b940084d7 2026-09-28)\nbinary: rustc\ncommit-hash: b940084d7eb6a299eb4bfeb8e34901bc051e7ac4\ncommit-date: 2026-09-28\nhost: aarch64-unknown-linux-gnu\nrelease: 1.99.0\nLLVM version: 23.1.1\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/CACHEDIR.TAG b/crates/countersign-gateway/prototype-isolation-probe/target/CACHEDIR.TAG new file mode 100644 index 0000000..20d7c31 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/CACHEDIR.TAG @@ -0,0 +1,3 @@ +Signature: 8a477f597d28d172789f06886806bc55 +# This file is a cache directory tag created by cargo. +# For information about cache directory tags see https://bford.info/cachedir/ diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.cargo-artifact-lock b/crates/countersign-gateway/prototype-isolation-probe/target/release/.cargo-artifact-lock new file mode 100644 index 0000000..e69de29 diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.cargo-build-lock b/crates/countersign-gateway/prototype-isolation-probe/target/release/.cargo-build-lock new file mode 100644 index 0000000..e69de29 diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.cargo-lock b/crates/countersign-gateway/prototype-isolation-probe/target/release/.cargo-lock new file mode 100644 index 0000000..e69de29 diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/bin-isolation-probe b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/bin-isolation-probe new file mode 100644 index 0000000..d1cd99c --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/bin-isolation-probe @@ -0,0 +1 @@ +72fa28d41811c602 \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/bin-isolation-probe.json b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/bin-isolation-probe.json new file mode 100644 index 0000000..477cc98 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/bin-isolation-probe.json @@ -0,0 +1 @@ +{"rustc":7244470188377863884,"features":"[]","declared_features":"[]","target":12218276445456869961,"profile":854319013279132213,"path":4942398508502643691,"deps":[[18070707816531966863,"libc",false,11853295208726224446]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/isolation-probe-78135a7c460b42b6/dep-bin-isolation-probe","checksum":false}}],"rustflags":[],"config":9396254390672932401,"compile_kind":0} \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/dep-bin-isolation-probe b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/dep-bin-isolation-probe new file mode 100644 index 0000000..5c54f74 Binary files /dev/null and b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/dep-bin-isolation-probe differ diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/invoked.timestamp b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/isolation-probe-78135a7c460b42b6/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-54ae003d211a90e7/run-build-script-build-script-build b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-54ae003d211a90e7/run-build-script-build-script-build new file mode 100644 index 0000000..4c00ca5 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-54ae003d211a90e7/run-build-script-build-script-build @@ -0,0 +1 @@ +8430af7cddf2df56 \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-54ae003d211a90e7/run-build-script-build-script-build.json b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-54ae003d211a90e7/run-build-script-build-script-build.json new file mode 100644 index 0000000..307c997 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-54ae003d211a90e7/run-build-script-build-script-build.json @@ -0,0 +1 @@ +{"rustc":7244470188377863884,"features":"","declared_features":"","target":0,"profile":0,"path":0,"deps":[[18070707816531966863,"build_script_build",false,4011722116619456885]],"local":[{"RerunIfChanged":{"output":"release/build/libc-54ae003d211a90e7/output","paths":["build.rs"]}},{"RerunIfEnvChanged":{"var":"LIBC_BUILD_VERBOSE","val":null}},{"RerunIfEnvChanged":{"var":"RUST_LIBC_UNSTABLE_FREEBSD_VERSION","val":null}}],"rustflags":[],"config":0,"compile_kind":0} \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/build-script-build-script-build b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/build-script-build-script-build new file mode 100644 index 0000000..b57ee1c --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/build-script-build-script-build @@ -0,0 +1 @@ +7551ae920280ac37 \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/build-script-build-script-build.json b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/build-script-build-script-build.json new file mode 100644 index 0000000..86d679a --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/build-script-build-script-build.json @@ -0,0 +1 @@ +{"rustc":7244470188377863884,"features":"[\"default\", \"std\"]","declared_features":"[\"align\", \"const-extern-fn\", \"default\", \"extra_traits\", \"rustc-dep-of-std\", \"rustc-std-workspace-core\", \"std\", \"use_std\"]","target":5408242616063297496,"profile":4660699631208531281,"path":3108924039311900754,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/libc-5b62a56144055547/dep-build-script-build-script-build","checksum":false}}],"rustflags":[],"config":9396254390672932401,"compile_kind":0} \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/dep-build-script-build-script-build b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/dep-build-script-build-script-build new file mode 100644 index 0000000..ec3cb8b Binary files /dev/null and b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/dep-build-script-build-script-build differ diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/invoked.timestamp b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-5b62a56144055547/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/dep-lib-libc b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/dep-lib-libc new file mode 100644 index 0000000..ec3cb8b Binary files /dev/null and b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/dep-lib-libc differ diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/invoked.timestamp b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/lib-libc b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/lib-libc new file mode 100644 index 0000000..1359d68 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/lib-libc @@ -0,0 +1 @@ +3e5ef7dd305d7fa4 \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/lib-libc.json b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/lib-libc.json new file mode 100644 index 0000000..1e28061 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/.fingerprint/libc-aebea1749fc1a15b/lib-libc.json @@ -0,0 +1 @@ +{"rustc":7244470188377863884,"features":"[\"default\", \"std\"]","declared_features":"[\"align\", \"const-extern-fn\", \"default\", \"extra_traits\", \"rustc-dep-of-std\", \"rustc-std-workspace-core\", \"std\", \"use_std\"]","target":17682796336736096309,"profile":12904552893056240883,"path":12859706116575813970,"deps":[[18070707816531966863,"build_script_build",false,6259989040161828996]],"local":[{"CheckDepInfo":{"dep_info":"release/.fingerprint/libc-aebea1749fc1a15b/dep-lib-libc","checksum":false}}],"rustflags":[],"config":9396254390672932401,"compile_kind":0} \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/invoked.timestamp b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/output b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/output new file mode 100644 index 0000000..da46388 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/output @@ -0,0 +1,30 @@ +cargo:rerun-if-changed=build.rs +cargo:rerun-if-env-changed=LIBC_BUILD_VERBOSE +cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_FREEBSD_VERSION +cargo:rustc-check-cfg=cfg(libc_deny_warnings) +cargo:rustc-check-cfg=cfg(emscripten_old_stat_abi) +cargo:rustc-check-cfg=cfg(emscripten_fsblkcnt_is_32bit) +cargo:rustc-check-cfg=cfg(emscripten_sigset_large) +cargo:rustc-check-cfg=cfg(emscripten_nfds_is_ulong) +cargo:rustc-check-cfg=cfg(espidf_picolibc) +cargo:rustc-check-cfg=cfg(espidf_time32) +cargo:rustc-check-cfg=cfg(freebsd10) +cargo:rustc-check-cfg=cfg(freebsd11) +cargo:rustc-check-cfg=cfg(freebsd12) +cargo:rustc-check-cfg=cfg(freebsd13) +cargo:rustc-check-cfg=cfg(freebsd14) +cargo:rustc-check-cfg=cfg(freebsd15) +cargo:rustc-check-cfg=cfg(libc_elfv2) +cargo:rustc-check-cfg=cfg(vxworks_lt_25_09) +cargo:rustc-check-cfg=cfg(libc_pauthtest) +cargo:rustc-check-cfg=cfg(gnu_file_offset_bits64) +cargo:rustc-check-cfg=cfg(gnu_time_bits64) +cargo:rustc-check-cfg=cfg(linux_time_bits64) +cargo:rustc-check-cfg=cfg(musl_v1_2) +cargo:rustc-check-cfg=cfg(musl32_time64) +cargo:rustc-check-cfg=cfg(musl_redir_time64) +cargo:rustc-check-cfg=cfg(uclibc32_time64) +cargo:rustc-check-cfg=cfg(target_os,values("switch","aix","ohos","hurd","rtems","visionos","nuttx","cygwin","qurt","qnx","helenos")) +cargo:rustc-check-cfg=cfg(target_env,values("illumos","wasi","aix","ohos","nto71_iosock")) +cargo:rustc-check-cfg=cfg(target_arch,values("loongarch64","mips32r6","mips64r6","csky")) +cargo:rustc-cfg=linux_time_bits64 diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/root-output b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/root-output new file mode 100644 index 0000000..1a7797c --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/root-output @@ -0,0 +1 @@ +/home/sodre/.t3/worktrees/countersign/t3-26f407de-ddf9b5024cab1ef0/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/out \ No newline at end of file diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/stderr b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-54ae003d211a90e7/stderr new file mode 100644 index 0000000..e69de29 diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build-script-build b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build-script-build new file mode 100755 index 0000000..544f31e Binary files /dev/null and b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build-script-build differ diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build_script_build-5b62a56144055547 b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build_script_build-5b62a56144055547 new file mode 100755 index 0000000..544f31e Binary files /dev/null and b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build_script_build-5b62a56144055547 differ diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build_script_build-5b62a56144055547.d b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build_script_build-5b62a56144055547.d new file mode 100644 index 0000000..2b57461 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build_script_build-5b62a56144055547.d @@ -0,0 +1,5 @@ +/home/sodre/.t3/worktrees/countersign/t3-26f407de-ddf9b5024cab1ef0/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build_script_build-5b62a56144055547.d: /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/build.rs + +/home/sodre/.t3/worktrees/countersign/t3-26f407de-ddf9b5024cab1ef0/crates/countersign-gateway/prototype-isolation-probe/target/release/build/libc-5b62a56144055547/build_script_build-5b62a56144055547: /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/build.rs + +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/build.rs: diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/isolation_probe-78135a7c460b42b6 b/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/isolation_probe-78135a7c460b42b6 new file mode 100755 index 0000000..fcf4586 Binary files /dev/null and b/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/isolation_probe-78135a7c460b42b6 differ diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/isolation_probe-78135a7c460b42b6.d b/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/isolation_probe-78135a7c460b42b6.d new file mode 100644 index 0000000..59b8b01 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/isolation_probe-78135a7c460b42b6.d @@ -0,0 +1,5 @@ +/home/sodre/.t3/worktrees/countersign/t3-26f407de-ddf9b5024cab1ef0/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/isolation_probe-78135a7c460b42b6.d: src/main.rs + +/home/sodre/.t3/worktrees/countersign/t3-26f407de-ddf9b5024cab1ef0/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/isolation_probe-78135a7c460b42b6: src/main.rs + +src/main.rs: diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/libc-aebea1749fc1a15b.d b/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/libc-aebea1749fc1a15b.d new file mode 100644 index 0000000..7b13852 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/libc-aebea1749fc1a15b.d @@ -0,0 +1,71 @@ +/home/sodre/.t3/worktrees/countersign/t3-26f407de-ddf9b5024cab1ef0/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/libc-aebea1749fc1a15b.d: /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/lib.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/macros.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/linux_like/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/linux_like/pthread.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/pthread.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/unistd.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/asm/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/asm/socket.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/bcm.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/error.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/j1939.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/netlink.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/raw.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/futex.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_addr.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_link.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_packet.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/keyctl.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/membarrier.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/mount.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/netlink.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/pidfd.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/sctp.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/tls.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/types.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/bits/signum_generic.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/io/sys/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/io/sys/statvfs.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/posix/unistd.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/signal.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/socket/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/socket/sys/socket.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/bits/struct_mutex.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/pthread.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/socket.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/net/route.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sys.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/primitives.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/arch/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux_l4re_shared.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/arch/generic/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/types.rs + +/home/sodre/.t3/worktrees/countersign/t3-26f407de-ddf9b5024cab1ef0/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/liblibc-aebea1749fc1a15b.rlib: /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/lib.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/macros.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/linux_like/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/linux_like/pthread.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/pthread.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/unistd.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/asm/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/asm/socket.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/bcm.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/error.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/j1939.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/netlink.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/raw.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/futex.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_addr.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_link.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_packet.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/keyctl.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/membarrier.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/mount.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/netlink.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/pidfd.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/sctp.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/tls.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/types.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/bits/signum_generic.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/io/sys/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/io/sys/statvfs.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/posix/unistd.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/signal.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/socket/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/socket/sys/socket.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/bits/struct_mutex.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/pthread.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/socket.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/net/route.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sys.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/primitives.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/arch/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux_l4re_shared.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/arch/generic/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/types.rs + +/home/sodre/.t3/worktrees/countersign/t3-26f407de-ddf9b5024cab1ef0/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/liblibc-aebea1749fc1a15b.rmeta: /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/lib.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/macros.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/linux_like/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/linux_like/pthread.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/pthread.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/unistd.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/asm/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/asm/socket.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/bcm.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/error.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/j1939.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/netlink.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/raw.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/futex.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_addr.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_link.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_packet.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/keyctl.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/membarrier.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/mount.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/netlink.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/pidfd.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/sctp.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/tls.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/types.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/bits/signum_generic.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/io/sys/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/io/sys/statvfs.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/posix/unistd.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/signal.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/socket/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/socket/sys/socket.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/bits/struct_mutex.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/pthread.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/socket.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/net/route.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sys.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/primitives.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/arch/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux_l4re_shared.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/arch/generic/mod.rs /home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/types.rs + +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/lib.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/macros.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/linux_like/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/linux_like/pthread.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/pthread.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/common/posix/unistd.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/asm/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/asm/socket.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/bcm.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/error.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/j1939.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/netlink.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/can/raw.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/futex.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_addr.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_link.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/if_packet.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/keyctl.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/membarrier.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/mount.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/netlink.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/pidfd.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/sctp.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/tls.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/linux_uapi/linux/types.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/bits/signum_generic.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/io/sys/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/io/sys/statvfs.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/posix/unistd.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/signal.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/socket/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/socket/sys/socket.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/bits/struct_mutex.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/nptl/pthread.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/sigaction.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/signum_arch.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/socket_type.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/socket.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/statvfs.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/types/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/bits/types/siginfo_t.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sysdeps/unix/linux/net/route.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/new/glibc/sys.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/primitives.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/arch/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux_l4re_shared.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/gnu/b64/aarch64/lp64.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/unix/linux_like/linux/arch/generic/mod.rs: +/home/sodre/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.191/src/types.rs: diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/liblibc-aebea1749fc1a15b.rlib b/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/liblibc-aebea1749fc1a15b.rlib new file mode 100644 index 0000000..c7a6412 Binary files /dev/null and b/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/liblibc-aebea1749fc1a15b.rlib differ diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/liblibc-aebea1749fc1a15b.rmeta b/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/liblibc-aebea1749fc1a15b.rmeta new file mode 100644 index 0000000..b77b451 Binary files /dev/null and b/crates/countersign-gateway/prototype-isolation-probe/target/release/deps/liblibc-aebea1749fc1a15b.rmeta differ diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/isolation-probe b/crates/countersign-gateway/prototype-isolation-probe/target/release/isolation-probe new file mode 100755 index 0000000..fcf4586 Binary files /dev/null and b/crates/countersign-gateway/prototype-isolation-probe/target/release/isolation-probe differ diff --git a/crates/countersign-gateway/prototype-isolation-probe/target/release/isolation-probe.d b/crates/countersign-gateway/prototype-isolation-probe/target/release/isolation-probe.d new file mode 100644 index 0000000..0564bf5 --- /dev/null +++ b/crates/countersign-gateway/prototype-isolation-probe/target/release/isolation-probe.d @@ -0,0 +1 @@ +/home/sodre/.t3/worktrees/countersign/t3-26f407de-ddf9b5024cab1ef0/crates/countersign-gateway/prototype-isolation-probe/target/release/isolation-probe: /home/sodre/.t3/worktrees/countersign/t3-26f407de-ddf9b5024cab1ef0/crates/countersign-gateway/prototype-isolation-probe/src/main.rs diff --git a/crates/countersign-gateway/src/lib.rs b/crates/countersign-gateway/src/lib.rs index 1c474c5..393b2eb 100644 --- a/crates/countersign-gateway/src/lib.rs +++ b/crates/countersign-gateway/src/lib.rs @@ -8,3 +8,7 @@ pub mod upstream; mod shared_issuer; pub use shared_issuer::{SharedCaSource, SharedIssuer}; + +/// The worker sandbox's base layers, which every grant worker applies to itself. +#[cfg(target_os = "linux")] +pub mod worker_sandbox; diff --git a/crates/countersign-gateway/src/main.rs b/crates/countersign-gateway/src/main.rs index 96d40b2..13f6ddd 100644 --- a/crates/countersign-gateway/src/main.rs +++ b/crates/countersign-gateway/src/main.rs @@ -6,6 +6,11 @@ fn main() -> Result<(), Box> { nix::sys::resource::setrlimit(nix::sys::resource::Resource::RLIMIT_CORE, 0, 0)?; nix::sys::prctl::set_dumpable(false)?; let args: Vec<_> = std::env::args().skip(1).collect(); + if args == ["grant-worker"] { + // Before the async runtime exists: the worker sandbox is applied by a + // process with one thread that has read no input. + return runtime::grant_worker(); + } tokio::runtime::Builder::new_current_thread() .enable_all() .build()? diff --git a/crates/countersign-gateway/src/runtime/mod.rs b/crates/countersign-gateway/src/runtime/mod.rs index 7e63958..ceaea2f 100644 --- a/crates/countersign-gateway/src/runtime/mod.rs +++ b/crates/countersign-gateway/src/runtime/mod.rs @@ -118,6 +118,7 @@ impl Gateway { return Err(Capacity.into()); } let (fence, closed) = watch::channel(false); + let (process, exit) = ChildHandle::launch()?; let slot = Slot { fence, requests: Arc::new(Semaphore::new(32)), @@ -128,11 +129,12 @@ impl Gateway { .unwrap_or_else(|| Arc::new(Semaphore::new(128))), binding: grant.clone(), expires: activate.expires_at_ms, - process: Some(ChildHandle::launch()?), + process: Some(process), connections: Arc::new(Semaphore::new(32)), handshakes: Arc::new(Semaphore::new(4)), }; children.insert(grant.grant.clone(), slot); + tokio::spawn(self.clone().watch_worker(grant.clone(), exit)); tokio::spawn(self.clone().watch_retirement( grant.clone(), credential.clone(), @@ -178,6 +180,23 @@ impl Gateway { } } + /// A grant worker that ends on its own, whatever the cause, has failed: + /// its grant is fenced and needs fresh approval. + async fn watch_worker(self: Arc, grant: GrantBinding, exit: worker::Exit) { + // An error means the supervisor stopped the grant worker itself. + if let Ok(status) = exit.await { + let id = grant.grant.as_str(); + if worker::killed_by_filter(status) { + eprintln!( + "Gateway grant {id}: grant worker killed by the worker sandbox's filter (SIGSYS); grant fenced" + ); + } else { + eprintln!("Gateway grant {id}: grant worker ended ({status}); grant fenced"); + } + self.fence(&grant); + } + } + async fn watch_retirement( self: Arc, grant: GrantBinding, @@ -832,10 +851,19 @@ async fn proxy( .await; } -pub async fn run(args: &[String]) -> Result<()> { - if args == ["grant-worker"] { - return worker::serve(); +/// A grant worker's whole life: it confines itself, then serves its grant. +pub fn grant_worker() -> Result<()> { + match countersign_gateway::worker_sandbox::confine() { + Ok(layers) => worker::serve(layers), + Err(error) => { + // The startup probe passes this on: the layer, then the cause. + eprintln!("{error}"); + std::process::exit(1); + } } +} + +pub async fn run(args: &[String]) -> Result<()> { let [verb, path] = args else { return Err(invalid("usage: countersign-gateway serve|env CONFIG.json")); }; @@ -847,7 +875,8 @@ pub async fn run(args: &[String]) -> Result<()> { if verb != "serve" { return Err(invalid("unrecognized Gateway command")); } - ChildHandle::verify_environment().await?; + let layers = ChildHandle::verify_environment().await?; + eprintln!("Gateway worker sandbox \"namespaces\": namespaces, {layers}"); let policy = config.policy()?; let broker = Broker::new(&config)?; let (issuer, tls) = if let Some(shared) = &config.shared { diff --git a/crates/countersign-gateway/src/runtime/worker.rs b/crates/countersign-gateway/src/runtime/worker.rs index 74293d4..ce571be 100644 --- a/crates/countersign-gateway/src/runtime/worker.rs +++ b/crates/countersign-gateway/src/runtime/worker.rs @@ -1,5 +1,8 @@ use base64::{Engine, engine::general_purpose::STANDARD}; -use countersign_gateway::upstream::{self, SigningRelay}; +use countersign_gateway::{ + upstream::{self, SigningRelay}, + worker_sandbox::{Landlock, Layers}, +}; use countersign_protocol::{ Origin, wire::{GatewayActivation, SignatureScheme as Scheme, TlsVersion}, @@ -16,9 +19,12 @@ use std::{ io::{IoSlice, IoSliceMut, Read, Write}, os::{ fd::{AsRawFd, FromRawFd, OwnedFd}, - unix::net::{UnixDatagram, UnixStream}, + unix::{ + net::{UnixDatagram, UnixStream}, + process::ExitStatusExt, + }, }, - process::{Command, Stdio}, + process::{Command, ExitStatus, Stdio}, sync::{ Arc, Mutex, atomic::{AtomicUsize, Ordering}, @@ -122,35 +128,88 @@ fn sandbox(executable: &std::path::Path) -> Command { command } +/// Resolves with a grant worker's exit status when it ends on its own, and +/// with an error when the supervisor stopped it. +pub type Exit = tokio::sync::oneshot::Receiver; + +/// Whether the seccomp allow-list killed this grant worker. bubblewrap, which +/// the supervisor waits on under the namespace sandbox, reports its child's +/// fatal signal as an exit code of 128 plus the signal (measured with +/// bubblewrap 0.9.0 on 2026-11-19: `bwrap ... sh -c 'kill -SYS $$'` exits 159). +pub fn killed_by_filter(status: ExitStatus) -> bool { + let sigsys = nix::libc::SIGSYS; + status.signal() == Some(sigsys) || status.code() == Some(128 + sigsys) +} + +/// The startup probe's report of a grant worker's layers, in one byte: the +/// Landlock ABI, or 0 for none. +fn report(layers: Layers) -> [u8; 1] { + match layers.landlock { + Landlock::Unavailable => [0], + Landlock::Abi(abi) => [abi], + } +} +fn reported(report: [u8; 1]) -> Layers { + Layers { + landlock: match report { + [0] => Landlock::Unavailable, + [abi] => Landlock::Abi(abi), + }, + } +} + pub struct ChildHandle { - child: tokio::process::Child, control: UnixDatagram, + /// Dropping this stops the grant worker. + _stop: tokio::sync::oneshot::Sender<()>, } impl ChildHandle { - fn start(stderr: Stdio) -> Result { + fn start(stderr: Stdio) -> Result<(tokio::process::Child, UnixDatagram)> { let (control, child_control) = UnixDatagram::pair()?; control.set_nonblocking(true)?; - let child = tokio::process::Command::from(sandbox(&std::env::current_exe()?)) + let process = tokio::process::Command::from(sandbox(&std::env::current_exe()?)) .kill_on_drop(true) .arg("grant-worker") .stdin(Stdio::from(OwnedFd::from(child_control))) .stdout(Stdio::null()) .stderr(stderr) .spawn()?; - Ok(Self { child, control }) + Ok((process, control)) } - pub fn launch() -> Result { - Self::start(Stdio::null()) + pub fn launch() -> Result<(Self, Exit)> { + let (mut process, control) = Self::start(Stdio::null())?; + let (stop, mut stopped) = tokio::sync::oneshot::channel::<()>(); + let (report, exit) = tokio::sync::oneshot::channel(); + tokio::spawn(async move { + tokio::select! { + status = process.wait() => { + if let Ok(status) = status { + let _ = report.send(status); + } + } + _ = &mut stopped => { + let _ = process.kill().await; + } + } + }); + Ok(( + Self { + control, + _stop: stop, + }, + exit, + )) } /// Check the actual host sandbox, executable and control socket at startup. - /// This short-lived worker receives no grant, credentials or traffic. - pub async fn verify_environment() -> Result<()> { - let probe = Self::start(Stdio::piped())?; - probe.control.send(&[0])?; + /// This short-lived worker receives no grant, credentials or traffic. It + /// confines itself as every grant worker does and reports its layers. + pub async fn verify_environment() -> Result { + let (process, control) = Self::start(Stdio::piped())?; + control.send(&[0])?; let output = - tokio::time::timeout(Duration::from_secs(5), probe.child.wait_with_output()).await??; + tokio::time::timeout(Duration::from_secs(5), process.wait_with_output()).await??; if !output.status.success() { let hint: String = String::from_utf8_lossy(&output.stderr) .split_whitespace() @@ -165,13 +224,15 @@ impl ChildHandle { )) .into()); } - Ok(()) + // The report was queued before the probe exited. + let mut message = [0u8; 2]; + match control.recv(&mut message) { + Ok(1) => Ok(reported([message[0]])), + _ => Err(invalid("grant worker reported no worker sandbox layers")), + } } pub fn attach(&mut self) -> Result<[tokio::net::UnixStream; 3]> { - if self.child.try_wait()?.is_some() { - return Err(invalid("grant worker exited")); - } let (a, b) = UnixStream::pair()?; let (c, d) = UnixStream::pair()?; let (e, f) = UnixStream::pair()?; @@ -191,7 +252,7 @@ impl ChildHandle { } } -pub fn serve() -> Result<()> { +pub fn serve(layers: Layers) -> Result<()> { // No secrets or network sockets are inherited. The authenticated parent // delivers three fresh, connected local stream endpoints per connection. let active = Arc::new(AtomicUsize::new(0)); @@ -218,7 +279,18 @@ pub fn serve() -> Result<()> { return Err(invalid("invalid worker dispatch")); } if byte == [0] && received.is_empty() { - return Ok(()); + // The startup probe. It reports this grant worker's layers from + // where a connection is served, a thread with an async runtime, so + // a host that the allow-list cannot serve on fails at startup. + return std::thread::spawn(move || -> Result<()> { + tokio::runtime::Builder::new_current_thread() + .enable_all() + .build()?; + nix::unistd::write(std::io::stdin(), &report(layers))?; + Ok(()) + }) + .join() + .map_err(|_| invalid("worker sandbox probe panicked"))?; } if byte != [1] { return Err(invalid("invalid worker control command")); @@ -231,12 +303,11 @@ pub fn serve() -> Result<()> { } active.fetch_add(1, Ordering::AcqRel); let active = active.clone(); - std::thread::Builder::new() - .name("grant-connection".into()) - .spawn(move || { - let _ = run(down, up, control); - active.fetch_sub(1, Ordering::AcqRel); - })?; + // Unnamed: naming a thread is one more system call to allow. + std::thread::Builder::new().spawn(move || { + let _ = run(down, up, control); + active.fetch_sub(1, Ordering::AcqRel); + })?; } } diff --git a/crates/countersign-gateway/src/worker_sandbox.rs b/crates/countersign-gateway/src/worker_sandbox.rs new file mode 100644 index 0000000..33c65ed --- /dev/null +++ b/crates/countersign-gateway/src/worker_sandbox.rs @@ -0,0 +1,356 @@ +//! The worker sandbox's base layers (ADR 0001): what every grant worker +//! applies to itself, under the namespace sandbox and the filter sandbox alike. + +use nix::libc; +use std::{fmt, io}; + +/// What Landlock gave the grant worker. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Landlock { + /// Every access right of this ABI is handled, and none is granted. + Abi(u8), + /// The kernel has no Landlock, or it is disabled. The other layers hold. + Unavailable, +} + +/// The base layers a confined grant worker runs under. Non-dumpable memory and +/// the seccomp allow-list are always among them; Landlock depends on the kernel. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Layers { + pub landlock: Landlock, +} + +impl fmt::Display for Layers { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str("non-dumpable, ")?; + match self.landlock { + Landlock::Abi(abi) => write!(f, "Landlock ABI v{abi}")?, + Landlock::Unavailable => f.write_str("Landlock unavailable")?, + } + f.write_str(", seccomp allow-list") + } +} + +/// A base layer, as [`ConfineError`] names it. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Layer { + NonDumpable, + Landlock, + AllowList, +} + +impl fmt::Display for Layer { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_str(match self { + Layer::NonDumpable => "non-dumpable", + Layer::Landlock => "Landlock", + Layer::AllowList => "seccomp allow-list", + }) + } +} + +/// The layer that could not be applied, and why. The layers before it stay +/// applied, so the caller can only exit. +#[derive(Debug, thiserror::Error)] +#[error("{layer}: {source}")] +pub struct ConfineError { + pub layer: Layer, + #[source] + pub source: io::Error, +} + +/// Confine the calling process as a grant worker. +/// +/// Call it while the process has one thread and before it reads any input. +/// Afterwards the process can use the descriptors it holds and those it +/// receives over them, run threads, and signal itself. Any other system call +/// kills it with `SIGSYS`. +pub fn confine() -> Result { + let at = |layer| move |source| ConfineError { layer, source }; + prctl(libc::PR_SET_DUMPABLE, 0).map_err(at(Layer::NonDumpable))?; + // The allow-list's no_new_privs, set ahead of Landlock and not after it: + // an unprivileged landlock_restrict_self fails with EPERM without it + // (landlock_restrict_self(2)). + prctl(libc::PR_SET_NO_NEW_PRIVS, 1) + .map_err(|error| io::Error::new(error.kind(), format!("no_new_privs: {error}"))) + .map_err(at(Layer::AllowList))?; + let landlock = landlock().map_err(at(Layer::Landlock))?; + allow_list().map_err(at(Layer::AllowList))?; + Ok(Layers { landlock }) +} + +fn check(result: libc::c_long) -> io::Result { + if result < 0 { + Err(io::Error::last_os_error()) + } else { + Ok(result) + } +} + +fn prctl(option: libc::c_int, value: libc::c_ulong) -> io::Result<()> { + // SAFETY: both options take one integer and no pointers. + check(unsafe { libc::prctl(option, value, 0, 0, 0) }.into()).map(drop) +} + +/// The newest Landlock ABI whose access rights are listed below. A newer +/// kernel is confined as this ABI, and reported as it. +const LANDLOCK_ABI: u8 = 7; + +#[repr(C)] +struct RulesetAttr { + handled_access_fs: u64, + handled_access_net: u64, + scoped: u64, +} + +/// A rule set that handles every access right the kernel's ABI knows and +/// grants none: no file access, no TCP bind or connect from ABI 4, and no +/// signal or abstract-socket reach outside the grant worker from ABI 6. +fn landlock() -> io::Result { + const VERSION: u32 = 1; + // SAFETY: a null attribute with size 0 is the documented version query. + let abi = match check(unsafe { + libc::syscall( + libc::SYS_landlock_create_ruleset, + std::ptr::null::(), + 0usize, + VERSION, + ) + }) { + Ok(abi) => abi.min(LANDLOCK_ABI.into()) as u8, + // Not built into the kernel, disabled at boot (landlock(7)), or denied + // by a container profile older than Landlock, which answers EPERM. + // Only this query may be refused: once the kernel has named an ABI, a + // failure to apply it is an error. + Err(error) + if matches!( + error.raw_os_error(), + Some(libc::ENOSYS | libc::EOPNOTSUPP | libc::EPERM) + ) => + { + return Ok(Landlock::Unavailable); + } + Err(error) => return Err(error), + }; + let attr = RulesetAttr { + // ABI 1 has 13 file rights. REFER (2), TRUNCATE (3) and IOCTL_DEV (5) + // each added one bit. + handled_access_fs: match abi { + 1 => 0x1fff, + 2 => 0x3fff, + 3 | 4 => 0x7fff, + _ => 0xffff, + }, + handled_access_net: if abi >= 4 { 0b11 } else { 0 }, + scoped: if abi >= 6 { 0b11 } else { 0 }, + }; + // An older kernel rejects a structure longer than the one it knows. + let size: usize = match abi { + ..4 => 8, + 4 | 5 => 16, + _ => 24, + }; + // SAFETY: `attr` outlives the call and `size` is within it. + let ruleset = + check(unsafe { libc::syscall(libc::SYS_landlock_create_ruleset, &attr, size, 0u32) })? + as libc::c_int; + // SAFETY: `ruleset` is the descriptor just created, closed exactly once. + let restricted = + check(unsafe { libc::syscall(libc::SYS_landlock_restrict_self, ruleset, 0u32) }); + unsafe { libc::close(ruleset) }; + restricted?; + Ok(Landlock::Abi(abi)) +} + +#[cfg(target_arch = "x86_64")] +const AUDIT_ARCH: u32 = 0xC000_003E; +#[cfg(target_arch = "aarch64")] +const AUDIT_ARCH: u32 = 0xC000_00B7; + +/// What a confined grant worker needs, and nothing else. +const ALLOWED: &[libc::c_long] = &[ + // Receiving its streams, then reading and writing them. + libc::SYS_recvmsg, + libc::SYS_recvfrom, + libc::SYS_read, + libc::SYS_write, + libc::SYS_writev, + libc::SYS_close, + libc::SYS_shutdown, + libc::SYS_setsockopt, + libc::SYS_epoll_create1, + libc::SYS_epoll_ctl, + libc::SYS_epoll_pwait, + #[cfg(target_arch = "x86_64")] + libc::SYS_epoll_wait, + libc::SYS_eventfd2, + // Threads and their synchronisation. + libc::SYS_clone3, + libc::SYS_set_robust_list, + libc::SYS_rseq, + libc::SYS_futex, + libc::SYS_sigaltstack, + libc::SYS_rt_sigprocmask, + // The C library installs its thread-cancellation handler with the first thread. + libc::SYS_rt_sigaction, + // Returning from a signal handler. Without it a crash that a handler + // sees first would end as a filter kill, and be logged as one. + libc::SYS_rt_sigreturn, + libc::SYS_sched_yield, + // A new thread asks the C library for its own attributes, CPU set included. + libc::SYS_sched_getaffinity, + libc::SYS_restart_syscall, + // Memory. + libc::SYS_mmap, + libc::SYS_munmap, + libc::SYS_mprotect, + libc::SYS_mremap, + libc::SYS_madvise, + libc::SYS_brk, + // Randomness and clocks. + libc::SYS_getrandom, + libc::SYS_clock_gettime, + // Exit. `abort` looks up the process and thread to signal first. + libc::SYS_exit, + libc::SYS_exit_group, + libc::SYS_getpid, + libc::SYS_gettid, +]; + +/// Offsets into `struct seccomp_data`, on a little-endian machine. +const DATA_NR: u32 = 0; +const DATA_ARCH: u32 = 4; +const DATA_ARG0: u32 = 16; +const DATA_ARG1: u32 = 24; +const DATA_ARG4: u32 = 48; + +/// What one word of a system call's arguments has to be. +enum Test<'a> { + /// One of these values. + OneOf(&'a [u32]), + /// Any value with this bit set. + Bit(u32), +} + +/// The seccomp filter. A system call outside it kills the whole process. +fn allow_list() -> io::Result<()> { + const LOAD: u16 = (libc::BPF_LD | libc::BPF_W | libc::BPF_ABS) as u16; + const EQUAL: u16 = (libc::BPF_JMP | libc::BPF_JEQ | libc::BPF_K) as u16; + const BIT_SET: u16 = (libc::BPF_JMP | libc::BPF_JSET | libc::BPF_K) as u16; + const RETURN: u16 = (libc::BPF_RET | libc::BPF_K) as u16; + let op = |code, k, jt, jf| libc::sock_filter { code, jt, jf, k }; + let allow = op(RETURN, libc::SECCOMP_RET_ALLOW, 0, 0); + let kill = op(RETURN, libc::SECCOMP_RET_KILL_PROCESS, 0, 0); + let number = |nr: libc::c_long| nr as u32; + + let mut filter = vec![ + // A foreign architecture numbers its system calls differently. + op(LOAD, DATA_ARCH, 0, 0), + op(EQUAL, AUDIT_ARCH, 1, 0), + kill, + op(LOAD, DATA_NR, 0, 0), + ]; + // x32 shares x86-64's architecture value and sets this bit in the number. + #[cfg(target_arch = "x86_64")] + filter.extend([ + op( + (libc::BPF_JMP | libc::BPF_JGE | libc::BPF_K) as u16, + 0x4000_0000, + 0, + 1, + ), + kill, + ]); + for nr in ALLOWED { + filter.extend([op(EQUAL, number(*nr), 0, 1), allow]); + } + // These are allowed only when every listed word of their arguments passes + // its test. The kernel reads each argument tested below as a 32-bit + // integer, bar the pointer, so the low word is the whole argument. + let own_pid = [std::process::id()]; + let conditional: [(libc::c_long, &[(u32, Test)]); 7] = [ + // A grant worker may signal only itself (ADR 0001, decision 6). + (libc::SYS_kill, &[(DATA_ARG0, Test::OneOf(&own_pid))]), + (libc::SYS_tgkill, &[(DATA_ARG0, Test::OneOf(&own_pid))]), + // Duplicating a stream's descriptor and reading its flags. Not + // F_SETOWN, which has the kernel signal a process of the caller's choice. + ( + libc::SYS_fcntl, + &[( + DATA_ARG1, + Test::OneOf(&[ + libc::F_DUPFD_CLOEXEC as u32, + libc::F_GETFD as u32, + libc::F_GETFL as u32, + ]), + )], + ), + // A thread, where the host has no clone3: Docker's default profile + // answers clone3 with ENOSYS, and the C library falls back to clone. + // Unlike clone3's, clone's flags are an argument the filter can read. + ( + libc::SYS_clone, + &[(DATA_ARG0, Test::Bit(libc::CLONE_THREAD as u32))], + ), + // The async runtime wakes itself over a local socket pair, which + // reaches nothing outside the grant worker. + ( + libc::SYS_socketpair, + &[(DATA_ARG0, Test::OneOf(&[libc::AF_UNIX as u32]))], + ), + // Switching a received stream between blocking and non-blocking. + ( + libc::SYS_ioctl, + &[(DATA_ARG1, Test::OneOf(&[libc::FIONBIO as u32]))], + ), + // Writing a stream. A null destination, both words of the pointer: + // with one, a datagram socket could reach a socket it was not given. + ( + libc::SYS_sendto, + &[ + (DATA_ARG4, Test::OneOf(&[0])), + (DATA_ARG4 + 4, Test::OneOf(&[0])), + ], + ), + ]; + for (nr, tests) in conditional { + let mut block = Vec::new(); + for (word, test) in tests { + block.push(op(LOAD, *word, 0, 0)); + match test { + Test::OneOf(values) => { + // A match jumps past the values left to try and the kill. + for (tried, value) in values.iter().enumerate() { + block.push(op(EQUAL, *value, (values.len() - tried) as u8, 0)); + } + } + Test::Bit(bit) => block.push(op(BIT_SET, *bit, 1, 0)), + } + block.push(kill); + } + block.push(allow); + // Another system call skips the block. Inside it every path ends in + // the kill or the allow, so nothing falls through to the next one. + filter.push(op(EQUAL, number(nr), 0, block.len() as u8)); + filter.extend(block); + } + filter.push(kill); + + let program = libc::sock_fprog { + len: filter.len() as u16, + filter: filter.as_mut_ptr(), + }; + // SAFETY: `program` points at `filter`, which outlives the call. The + // kernel copies the filter. + check( + unsafe { + libc::prctl( + libc::PR_SET_SECCOMP, + libc::SECCOMP_MODE_FILTER, + &program as *const libc::sock_fprog, + ) + } + .into(), + ) + .map(drop) +} diff --git a/crates/countersign-gateway/tests/runtime.py b/crates/countersign-gateway/tests/runtime.py index 5778284..48b9ee3 100644 --- a/crates/countersign-gateway/tests/runtime.py +++ b/crates/countersign-gateway/tests/runtime.py @@ -12,6 +12,7 @@ import http.server import json import os +import re from pathlib import Path import signal import socket @@ -178,7 +179,7 @@ def server(addr, handler, tls): thread.join() -def do_test(dir, binary, ip,site, broker, identities, ca, shared): +def do_test(dir, binary, ip,site, broker, identities, ca, shared, filter_kill=False): host = f'site.test:{site.server_port}' broker.host = host broker.accounts = {} @@ -226,8 +227,24 @@ def do_test(dir, binary, ip,site, broker, identities, ca, shared): # Override /etc/hosts only for the Gateway parent. Grant workers are then # isolated by the production launcher and receive only preconnected streams. library = os.environ.get('NSS_WRAPPER_LIBRARY') or str(next(Path('/usr/lib').glob('*/libnss_wrapper.so'))) - with subprocess.Popen([binary,'serve',str(dir/'config.json')], + with subprocess.Popen([binary,'serve',str(dir/'config.json')], stderr=subprocess.PIPE, text=True, env={**os.environ,'LD_PRELOAD':library,'NSS_WRAPPER_HOSTS':str(hosts)}) as child: + log = [] + logged = threading.Condition() + def follow(): + for line in child.stderr: + sys.stderr.write(line) + with logged: + log.append(line.rstrip('\n')) + logged.notify_all() + threading.Thread(target=follow, daemon=True).start() + def wait_for_log(pattern, timeout=4): + with logged: + return logged.wait_for(lambda: any(re.fullmatch(pattern, line) for line in log), timeout) + def descendants(pid): + child_list = Path(f'/proc/{pid}/task/{pid}/children') + direct = [int(c) for c in child_list.read_text().split()] + return direct + [p for c in direct for p in descendants(c)] try: for _ in range(100): if child.poll() is not None: @@ -239,6 +256,9 @@ def do_test(dir, binary, ip,site, broker, identities, ca, shared): threading.Event().wait(.05) else: raise RuntimeError('Gateway did not start') + # Startup names the worker sandbox and every layer its probe worker applied. + assert wait_for_log(r'Gateway worker sandbox "namespaces": namespaces, non-dumpable, ' + r'Landlock (ABI v[1-9]\d*|unavailable), seccomp allow-list'), log def request(user,extra=(),path='/', timeout=8): args=['curl','--silent','--show-error','--fail','--max-time',str(timeout),'--noproxy','','--proxy',proxy, '--proxy-cacert',str(dir/'ca.pem'),'--cacert',str(pub)] @@ -246,6 +266,22 @@ def request(user,extra=(),path='/', timeout=8): args+=['--proxy-header','Proxy-Authorization: Bearer '+token(bindings[user])] return subprocess.run(args + list(extra) + ['https://'+host+path], capture_output=True, timeout=timeout+2) users = list(identities) if shared else ['alice'] + if filter_kill: + # Only Alice's grant worker runs. A grant worker the allow-list + # kills dies of SIGSYS, so deliver that signal to it: the + # supervisor cannot tell the two apart. + assert request('alice').returncode == 0 + leaves = [pid for pid in descendants(child.pid) if not descendants(pid)] + assert len(leaves) == 1, leaves + os.kill(leaves[0], signal.SIGSYS) + assert wait_for_log(r"Gateway grant alice: grant worker killed by the worker sandbox's filter \(SIGSYS\); " + r'grant fenced'), log + assert request('alice').returncode != 0, 'A grant whose worker the filter killed was served again' + assert request('bob').returncode == 0, "Alice's killed grant worker affected Bob" + # A fresh approval is a new grant, which gets a new grant worker. + broker.accounts[token(bindings['alice'])][2].update(grant='alice-approved-again') + assert request('alice').returncode == 0, 'A fresh approval did not restore service' + return with concurrent.futures.ThreadPoolExecutor(max_workers=len(users)) as pool: results = list(pool.map(request,users)) for user,res in zip(users,results): @@ -271,10 +307,6 @@ def request(user,extra=(),path='/', timeout=8): # The only grant belongs to Alice. Stop all of this launcher's # descendants, including the worker. Both network relays must # still enforce cutoff, without help from any child process. - def descendants(pid): - child_list = Path(f'/proc/{pid}/task/{pid}/children') - direct = [int(c) for c in child_list.read_text().split()] - return direct + [p for c in direct for p in descendants(c)] workers = descendants(child.pid) assert workers, 'isolated worker missing' for pid in workers: @@ -341,6 +373,8 @@ def tls(name): for shared in (False,True): do_test(dir,binary,ip,site,broker,identities,ca,shared) print(('shared' if shared else 'sidecar')+' Gateway mTLS passed') + do_test(dir,binary,ip,site,broker,identities,ca,True,filter_kill=True) + print('filter-killed grant worker fenced') if __name__ == '__main__': diff --git a/crates/countersign-gateway/tests/worker_sandbox.rs b/crates/countersign-gateway/tests/worker_sandbox.rs new file mode 100644 index 0000000..14eb88e --- /dev/null +++ b/crates/countersign-gateway/tests/worker_sandbox.rs @@ -0,0 +1,788 @@ +//! Two concurrent stand-in grant workers confine themselves through the +//! worker sandbox module, receive a stream as a grant worker does, and then +//! try what a compromised grant worker would try. +//! +//! This test is its own harness (`harness = false`): it starts the stand-ins +//! by running itself again, as the supervisor runs the Gateway executable, so +//! each stand-in confines a fresh process that has one thread. + +#[cfg(not(target_os = "linux"))] +fn main() {} + +#[cfg(target_os = "linux")] +fn main() { + linux::main() +} + +#[cfg(target_os = "linux")] +mod linux { + use countersign_gateway::worker_sandbox::confine; + use nix::{ + libc, + sys::socket::{ControlMessage, ControlMessageOwned, MsgFlags, recvmsg, sendmsg}, + }; + use std::{ + ffi::CString, + io::{BufRead, BufReader, IoSlice, IoSliceMut, Write}, + net::{TcpListener, UdpSocket}, + os::{ + fd::{AsRawFd, FromRawFd, OwnedFd}, + unix::{ + net::{UnixDatagram, UnixStream}, + process::{CommandExt, ExitStatusExt}, + }, + }, + process::{Child, Command, Stdio}, + time::{Duration, Instant}, + }; + + /// How a stand-in is set up: unconfined, confined, or confined on a host + /// that lacks or refuses one system call. + const UNCONFINED: &str = "unconfined"; + const CONFINED: &str = "confined"; + const NO_LANDLOCK: &str = "no-landlock"; + const LANDLOCK_REFUSED: &str = "landlock-refused"; + /// A container profile older than Landlock answers its calls this way. + const LANDLOCK_DENIED: &str = "landlock-denied"; + /// Docker's default profile answers `clone3` this way, and the C library + /// then starts threads with `clone`. + const NO_CLONE3: &str = "no-clone3"; + + /// Stands in for a secret in the supervisor's or a grant worker's memory. + static SECRET: [u8; 16] = *b"keep-this-secret"; + + pub fn main() { + let args: Vec = std::env::args().skip(1).collect(); + // Yama's default lets a process read only its descendants' memory, + // which alone would refuse every memory read below. The supervisor and + // each stand-in opt out, so the worker sandbox is what refuses them. + // SAFETY: the option takes one integer. Without Yama it fails, unneeded. + unsafe { libc::prctl(libc::PR_SET_PTRACER, libc::PR_SET_PTRACER_ANY, 0, 0, 0) }; + match args.as_slice() { + [role, setup] if role == "stand-in" => stand_in(setup), + // The Gateway's own grant worker, on a host with this quirk. + [role, setup, program, argument] if role == "stand-in" => { + host_quirk(setup); + let error = Command::new(program).arg(argument).exec(); + panic!("{program}: {error}"); + } + _ => {} + } + let mut failed = 0; + for (name, test) in TESTS { + match std::panic::catch_unwind(test) { + Ok(()) => println!("test {name} ... ok"), + Err(_) => { + println!("test {name} ... FAILED"); + failed += 1; + } + } + } + println!("{} passed, {failed} failed", TESTS.len() - failed); + std::process::exit(if failed == 0 { 0 } else { 1 }); + } + + // ---------- the stand-in grant worker ---------- + + /// A host that lacks or refuses one system call, stood in for by a filter + /// of the test's own that answers for the kernel. + fn host_quirk(setup: &str) { + match setup { + NO_LANDLOCK => fail_with(libc::SYS_landlock_create_ruleset, libc::ENOSYS), + LANDLOCK_REFUSED => fail_with(libc::SYS_landlock_restrict_self, libc::EPERM), + LANDLOCK_DENIED => fail_with(libc::SYS_landlock_create_ruleset, libc::EPERM), + NO_CLONE3 => fail_with(libc::SYS_clone3, libc::ENOSYS), + _ => assert_eq!(setup, CONFINED), + } + } + + extern "C" fn handled(_: libc::c_int) {} + + fn stand_in(setup: &str) -> ! { + // A handler to return from, installed as a C library installs its own. + // SAFETY: `handled` does nothing, which is safe in a signal handler. + unsafe { + libc::signal( + libc::SIGUSR1, + handled as extern "C" fn(libc::c_int) as usize, + ) + }; + let layers = if setup == UNCONFINED { + "unconfined".into() + } else { + host_quirk(setup); + match confine() { + Ok(layers) => layers.to_string(), + Err(error) => { + eprintln!("{error}"); + std::process::exit(3); + } + } + }; + // Its stream arrives over the control socket, as a grant worker's do. + let mut byte = [0u8; 1]; + let mut iov = [IoSliceMut::new(&mut byte)]; + let mut space = nix::cmsg_space!([i32; 1]); + let message = recvmsg::<()>(0, &mut iov, Some(&mut space), MsgFlags::MSG_CMSG_CLOEXEC) + .expect("control message"); + let stream = message + .cmsgs() + .expect("control data") + .find_map(|control| match control { + ControlMessageOwned::ScmRights(fds) => fds.first().copied(), + _ => None, + }) + .expect("a stream descriptor"); + // SAFETY: recvmsg allocated this descriptor for this process just now. + let stream = unsafe { UnixStream::from_raw_fd(stream) }; + // It serves the stream on a thread, as a grant worker serves a connection. + std::thread::spawn(move || serve(stream, &layers)) + .join() + .expect("stream thread"); + std::process::exit(0); + } + + /// Make one system call fail with `errno` from now on, as a kernel without + /// it, or a host that refuses it, would. + fn fail_with(nr: libc::c_long, errno: i32) { + let op = |code: u32, k: u32, jt, jf| libc::sock_filter { + code: code as u16, + jt, + jf, + k, + }; + let mut filter = [ + op(libc::BPF_LD | libc::BPF_W | libc::BPF_ABS, 0, 0, 0), + op(libc::BPF_JMP | libc::BPF_JEQ | libc::BPF_K, nr as u32, 0, 1), + op( + libc::BPF_RET | libc::BPF_K, + libc::SECCOMP_RET_ERRNO | errno as u32, + 0, + 0, + ), + op(libc::BPF_RET | libc::BPF_K, libc::SECCOMP_RET_ALLOW, 0, 0), + ]; + let program = libc::sock_fprog { + len: filter.len() as u16, + filter: filter.as_mut_ptr(), + }; + // SAFETY: `program` points at `filter`, which outlives both calls. + let installed = unsafe { + libc::prctl(libc::PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); + libc::prctl( + libc::PR_SET_SECCOMP, + libc::SECCOMP_MODE_FILTER, + &raw const program, + ) + }; + assert_eq!(installed, 0, "the test's own filter"); + } + + fn serve(stream: UnixStream, layers: &str) { + let mut reply = stream.try_clone().expect("stream clone"); + writeln!( + reply, + "ready {} {} {layers}", + std::process::id(), + SECRET.as_ptr() as usize + ) + .expect("ready line"); + for line in BufReader::new(stream).lines() { + let line = line.expect("command"); + let words: Vec<&str> = line.split(' ').collect(); + let number = |i: usize| words[i].parse::().expect("number"); + let result = match words[0] { + "ping" => Ok(()), + "open" => open(words[1]), + "tcp" => tcp(number(1) as u16), + "udp" => udp(number(1) as u16), + "exec" => exec(), + "read-memory" => read_memory(number(1) as libc::pid_t, number(2)), + "signal" => signal(number(1) as libc::pid_t, number(2) as libc::c_int), + "trace-me" => trace_me(), + "raise" => raise(number(1) as libc::c_int), + "fork" => fork(), + "signal-on-io" => signal_on_io(number(1) as libc::pid_t), + #[cfg(target_arch = "x86_64")] + "x32" => x32(), + #[cfg(target_arch = "x86_64")] + "i386" => i386(), + other => panic!("unknown command {other}"), + }; + match result { + Ok(()) => writeln!(reply, "ok"), + Err(errno) => writeln!(reply, "errno {errno}"), + } + .expect("reply line"); + } + } + + fn errno() -> i32 { + std::io::Error::last_os_error().raw_os_error().unwrap_or(0) + } + + fn checked(result: impl Into) -> Result<(), i32> { + if result.into() < 0 { + Err(errno()) + } else { + Ok(()) + } + } + + fn open(path: &str) -> Result<(), i32> { + let path = CString::new(path).unwrap(); + // SAFETY: `path` is a NUL-terminated string that outlives the call. + checked(unsafe { libc::open(path.as_ptr(), libc::O_RDONLY | libc::O_CLOEXEC) }) + } + + fn loopback(port: u16) -> libc::sockaddr_in { + libc::sockaddr_in { + sin_family: libc::AF_INET as _, + sin_port: port.to_be(), + sin_addr: libc::in_addr { + s_addr: u32::from_be_bytes([127, 0, 0, 1]).to_be(), + }, + sin_zero: [0; 8], + } + } + + fn tcp(port: u16) -> Result<(), i32> { + let address = loopback(port); + // SAFETY: `address` outlives the calls and its size is passed with it. + unsafe { + let socket = libc::socket(libc::AF_INET, libc::SOCK_STREAM | libc::SOCK_CLOEXEC, 0); + checked(socket)?; + checked(libc::connect( + socket, + (&raw const address).cast(), + size_of::() as _, + )) + } + } + + fn udp(port: u16) -> Result<(), i32> { + let address = loopback(port); + // SAFETY: the buffer and `address` outlive the calls, with their sizes. + unsafe { + let socket = libc::socket(libc::AF_INET, libc::SOCK_DGRAM | libc::SOCK_CLOEXEC, 0); + checked(socket)?; + checked(libc::sendto( + socket, + b"x".as_ptr().cast(), + 1, + 0, + (&raw const address).cast(), + size_of::() as _, + ) as i64) + } + } + + /// Replaces the stand-in with `/bin/true` when it gets through, so the + /// supervisor then sees a clean exit instead of a reply. + fn exec() -> Result<(), i32> { + let path = CString::new("/bin/true").unwrap(); + let argv = [path.as_ptr(), std::ptr::null()]; + // SAFETY: `argv` is a NULL-terminated array of NUL-terminated strings. + checked(unsafe { libc::execv(path.as_ptr(), argv.as_ptr()) }) + } + + fn read_memory(pid: libc::pid_t, address: usize) -> Result<(), i32> { + let mut buffer = [0u8; SECRET.len()]; + let local = libc::iovec { + iov_base: buffer.as_mut_ptr().cast(), + iov_len: buffer.len(), + }; + let remote = libc::iovec { + iov_base: address as *mut _, + iov_len: buffer.len(), + }; + // SAFETY: `local` points at `buffer`; the kernel validates `remote`. + checked(unsafe { libc::process_vm_readv(pid, &local, 1, &remote, 1, 0) } as i64) + } + + fn signal(pid: libc::pid_t, signal: libc::c_int) -> Result<(), i32> { + // SAFETY: kill takes two integers. + checked(unsafe { libc::kill(pid, signal) }) + } + + /// Signal this thread. The signal is handled, and its handler returned + /// from, before `raise` returns. + fn raise(signal: libc::c_int) -> Result<(), i32> { + // SAFETY: raise takes one integer. + checked(unsafe { libc::raise(signal) }) + } + + /// A second process, which ends at once. + fn fork() -> Result<(), i32> { + // SAFETY: the new process calls only `_exit`, which is async-signal-safe. + let pid = unsafe { libc::fork() }; + if pid == 0 { + unsafe { libc::_exit(0) }; + } + checked(pid) + } + + /// Ask the kernel to signal `pid` whenever the control socket has input: + /// a signal to another process that `kill` never sends. + fn signal_on_io(pid: libc::pid_t) -> Result<(), i32> { + // SAFETY: F_SETOWN takes one integer. + checked(unsafe { libc::fcntl(0, libc::F_SETOWN, pid) }) + } + + /// A system call no grant worker needs. + fn trace_me() -> Result<(), i32> { + // SAFETY: PTRACE_TRACEME takes no pointers. + checked(unsafe { libc::ptrace(libc::PTRACE_TRACEME, 0, 0, 0) }) + } + + /// `getpid` by its x32 number: x86-64's architecture value, another table. + #[cfg(target_arch = "x86_64")] + fn x32() -> Result<(), i32> { + // SAFETY: getpid takes no arguments. + checked(unsafe { libc::syscall(0x4000_0000 | libc::SYS_getpid) }) + } + + /// `getpid` by its i386 number, through the 32-bit entry point. + #[cfg(target_arch = "x86_64")] + fn i386() -> Result<(), i32> { + let result: i32; + // SAFETY: i386 system call 20 is getpid, which takes no arguments. + // `int 0x80` leaves every register but eax as it was. + unsafe { std::arch::asm!("int 0x80", inout("eax") 20 => result) }; + if result < 0 { Err(-result) } else { Ok(()) } + } + + // ---------- the supervisor's side ---------- + + struct StandIn { + process: Reaped, + pid: libc::pid_t, + secret: usize, + layers: String, + commands: UnixStream, + replies: BufReader, + } + + #[derive(Debug, PartialEq)] + enum Outcome { + /// The stand-in did it. + GotThrough, + /// The kernel answered with this error. + Errno(i32), + /// The stand-in died of this signal. + Killed(i32), + } + + impl Outcome { + fn refused(&self) -> bool { + matches!( + self, + Outcome::Killed(libc::SIGSYS) | Outcome::Errno(libc::EPERM | libc::EACCES) + ) + } + } + + impl StandIn { + /// Start a stand-in the way the supervisor starts a grant worker: a + /// fresh process, a cleared environment, the control socket as its + /// standard input, and its stream handed over by `SCM_RIGHTS`. + fn start(setup: &str) -> Self { + let (control, child_control) = UnixDatagram::pair().unwrap(); + let process = Command::new(std::env::current_exe().unwrap()) + .env_clear() + .args(["stand-in", setup]) + .stdin(Stdio::from(OwnedFd::from(child_control))) + .stdout(Stdio::null()) + .spawn() + .unwrap(); + let (stream, theirs) = UnixStream::pair().unwrap(); + sendmsg::<()>( + control.as_raw_fd(), + &[IoSlice::new(&[1])], + &[ControlMessage::ScmRights(&[theirs.as_raw_fd()])], + MsgFlags::MSG_NOSIGNAL, + None, + ) + .unwrap(); + drop(theirs); + let mut replies = BufReader::new(stream.try_clone().unwrap()); + let mut ready = String::new(); + replies.read_line(&mut ready).unwrap(); + let words: Vec<&str> = ready.trim_end().splitn(4, ' ').collect(); + assert_eq!(words[0], "ready", "the stand-in never served its stream"); + StandIn { + process: Reaped(process), + pid: words[1].parse().unwrap(), + secret: words[2].parse().unwrap(), + layers: words[3].to_owned(), + commands: stream, + replies, + } + } + + fn attempt(&mut self, command: &str) -> Outcome { + writeln!(self.commands, "{command}").unwrap(); + let mut reply = String::new(); + // A stand-in that died by the filter closes its stream instead. + let _ = self.replies.read_line(&mut reply); + match reply.trim_end().split_once(' ') { + _ if reply.trim_end() == "ok" => Outcome::GotThrough, + Some(("errno", errno)) => Outcome::Errno(errno.parse().unwrap()), + _ => { + let status = self.process.0.wait().unwrap(); + match status.signal() { + Some(signal) => Outcome::Killed(signal), + // Only a successful exec ends a stand-in cleanly. + None => { + assert_eq!(status.code(), Some(0), "stand-in failed: {status}"); + Outcome::GotThrough + } + } + } + } + } + } + + /// A process of the test's, stopped and reaped when the test lets go of it. + struct Reaped(Child); + impl Drop for Reaped { + fn drop(&mut self) { + let _ = self.0.kill(); + let _ = self.0.wait(); + } + } + + /// The Gateway's own grant worker, started as the supervisor starts it, + /// less bubblewrap, and optionally on a host with a quirk. + fn grant_worker(setup: Option<&str>) -> (Reaped, UnixDatagram) { + let gateway = env!("CARGO_BIN_EXE_countersign-gateway"); + let (control, worker_control) = UnixDatagram::pair().unwrap(); + control + .set_read_timeout(Some(Duration::from_secs(5))) + .unwrap(); + let mut command = match setup { + None => Command::new(gateway), + Some(setup) => { + let mut command = Command::new(std::env::current_exe().unwrap()); + command.args(["stand-in", setup, gateway]); + command + } + }; + let worker = command + .env_clear() + .arg("grant-worker") + .stdin(Stdio::from(OwnedFd::from(worker_control))) + .stdout(Stdio::null()) + .spawn() + .unwrap(); + (Reaped(worker), control) + } + + /// Asked as the startup probe asks, a grant worker reports its Landlock + /// layer in one byte and exits cleanly. + fn probe(worker: &mut Reaped, control: &UnixDatagram) { + control.send(&[0]).unwrap(); + let mut report = [0u8; 2]; + let received = control.recv(&mut report); + let status = worker.0.wait().unwrap(); + assert!( + status.success(), + "the probed grant worker ended with {status}" + ); + assert_eq!(received.unwrap(), 1); + } + + /// Yama's scope 2 and 3 refuse every unprivileged memory read, opt-out or + /// not, so there the unconfined reads cannot be shown to get through. + fn memory_reads_are_possible() -> bool { + std::fs::read_to_string("/proc/sys/kernel/yama/ptrace_scope") + .is_ok_and(|scope| matches!(scope.trim(), "0" | "1")) + } + + /// What the attempt is aimed at, when it needs a process to aim at. + struct Target { + supervisor_pid: u32, + supervisor_secret: usize, + other_pid: libc::pid_t, + other_secret: usize, + } + + /// Each of two concurrent stand-ins makes the attempt in turn, on a fresh + /// pair, while the other stand-in is alive to be its target. The other + /// stand-in must be unharmed afterwards. + fn each_of_two( + setup: &str, + command: impl Fn(&Target) -> String, + expect: impl Fn(&Outcome) -> bool, + expectation: &str, + ) { + for attacker in 0..2 { + let mut pair = [StandIn::start(setup), StandIn::start(setup)]; + let other = &pair[1 - attacker]; + let command = command(&Target { + supervisor_pid: std::process::id(), + supervisor_secret: SECRET.as_ptr() as usize, + other_pid: other.pid, + other_secret: other.secret, + }); + let outcome = pair[attacker].attempt(&command); + assert!( + expect(&outcome), + "stand-in {attacker}, `{command}`: expected {expectation}, got {outcome:?}" + ); + assert_eq!( + pair[1 - attacker].attempt("ping"), + Outcome::GotThrough, + "stand-in {attacker}'s `{command}` harmed the other stand-in" + ); + } + } + + fn refused(command: impl Fn(&Target) -> String) { + each_of_two(CONFINED, command, Outcome::refused, "a refusal"); + } + + /// Unconfined, the same attempt gets through: the attempt is real, and it + /// is the worker sandbox that refuses it. + fn refused_only_when_confined(command: impl Fn(&Target) -> String) { + each_of_two( + UNCONFINED, + &command, + |o| *o == Outcome::GotThrough, + "success", + ); + refused(command); + } + + type Test = (&'static str, fn()); + const TESTS: &[Test] = &[ + ("a_confined_grant_worker_reports_its_layers", || { + let stand_in = StandIn::start(CONFINED); + let layers: Vec<&str> = stand_in.layers.split(", ").collect(); + let [non_dumpable, landlock, allow_list] = layers[..] else { + panic!("{layers:?}"); + }; + assert_eq!(non_dumpable, "non-dumpable"); + assert_eq!(allow_list, "seccomp allow-list"); + // The kernel decides which. Either way the stand-in started. + let abi = landlock.strip_prefix("Landlock ABI v"); + assert!( + landlock == "Landlock unavailable" + || abi.is_some_and(|abi| abi.parse::().is_ok_and(|abi| abi >= 1)), + "{landlock}" + ); + }), + ("without_landlock_it_says_so_and_is_still_confined", || { + let stand_in = StandIn::start(NO_LANDLOCK); + assert_eq!( + stand_in.layers, + "non-dumpable, Landlock unavailable, seccomp allow-list" + ); + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + let port = listener.local_addr().unwrap().port(); + for command in ["open /".to_owned(), format!("tcp {port}"), "exec".into()] { + each_of_two( + NO_LANDLOCK, + |_| command.clone(), + Outcome::refused, + "a refusal", + ); + } + }), + ( + "a_host_that_denies_landlock_is_reported_as_without_it_and_still_confined", + || { + let stand_in = StandIn::start(LANDLOCK_DENIED); + assert_eq!( + stand_in.layers, + "non-dumpable, Landlock unavailable, seccomp allow-list" + ); + each_of_two( + LANDLOCK_DENIED, + |_| "open /".into(), + Outcome::refused, + "a refusal", + ); + }, + ), + ("a_layer_the_host_refuses_fails_confinement_by_name", || { + let output = Command::new(std::env::current_exe().unwrap()) + .env_clear() + .args(["stand-in", LANDLOCK_REFUSED]) + .stdin(Stdio::null()) + .output() + .unwrap(); + assert_eq!(output.status.code(), Some(3), "{output:?}"); + assert_eq!( + String::from_utf8_lossy(&output.stderr), + "Landlock: Operation not permitted (os error 1)\n" + ); + }), + ("its_stream_arrives_and_its_threads_work", || { + // `start` returns once the thread serving the stream said `ready`. + each_of_two( + CONFINED, + |_| "ping".into(), + |o| *o == Outcome::GotThrough, + "a reply", + ); + }), + ("opening_a_file_is_refused", || { + refused_only_when_confined(|_| "open /".into()); + }), + ("reading_the_supervisors_environment_is_refused", || { + refused_only_when_confined(|t| format!("open /proc/{}/environ", t.supervisor_pid)); + }), + ("reading_the_supervisors_memory_is_refused", || { + let read = + |t: &Target| format!("read-memory {} {}", t.supervisor_pid, t.supervisor_secret); + if memory_reads_are_possible() { + each_of_two(UNCONFINED, read, |o| *o == Outcome::GotThrough, "success"); + } + refused(read); + }), + ("reading_the_other_grant_workers_memory_is_refused", || { + let read = |t: &Target| format!("read-memory {} {}", t.other_pid, t.other_secret); + if memory_reads_are_possible() { + each_of_two(UNCONFINED, read, |o| *o == Outcome::GotThrough, "success"); + } + refused(read); + }), + ( + "an_unconfined_process_cannot_read_a_grant_workers_memory", + || { + // Non-dumpable memory, on its own: this reader runs under no filter. + let mut reader = StandIn::start(UNCONFINED); + let worker = StandIn::start(CONFINED); + assert_eq!( + reader.attempt(&format!("read-memory {} {}", worker.pid, worker.secret)), + Outcome::Errno(libc::EPERM) + ); + }, + ), + ( + "the_grant_worker_is_confined_before_it_is_sent_anything", + || { + let (mut worker, control) = grant_worker(None); + // A container's own filter may already cover both processes, so + // the grant worker's is the one more than this test runs under. + let filters = |pid: u32| { + let status = std::fs::read_to_string(format!("/proc/{pid}/status")).unwrap(); + let line = status + .lines() + .find(|line| line.starts_with("Seccomp_filters:")); + line.and_then(|line| line.split_whitespace().nth(1)?.parse::().ok()) + .expect("a kernel that counts seccomp filters (5.9)") + }; + let inherited = filters(std::process::id()); + let deadline = Instant::now() + Duration::from_secs(5); + // Nothing has been sent to it yet. + let mut confined = false; + while !confined && Instant::now() < deadline { + std::thread::sleep(Duration::from_millis(10)); + confined = filters(worker.0.id()) == inherited + 1; + } + assert!(confined, "the grant worker waited for input unconfined"); + probe(&mut worker, &control); + }, + ), + ("the_grant_worker_starts_on_a_host_without_clone3", || { + let (mut worker, control) = grant_worker(Some(NO_CLONE3)); + probe(&mut worker, &control); + }), + ("its_threads_work_on_a_host_without_clone3", || { + each_of_two( + NO_CLONE3, + |_| "ping".into(), + |o| *o == Outcome::GotThrough, + "a reply", + ); + }), + ("starting_another_process_is_refused", || { + refused_only_when_confined(|_| "fork".into()); + each_of_two(NO_CLONE3, |_| "fork".into(), Outcome::refused, "a refusal"); + }), + ( + "having_the_kernel_signal_another_process_is_refused", + || { + refused_only_when_confined(|t| format!("signal-on-io {}", t.other_pid)); + }, + ), + ("returning_from_a_signal_handler_works", || { + for worker in 0..2 { + let mut pair = [StandIn::start(CONFINED), StandIn::start(CONFINED)]; + let handled = format!("raise {}", libc::SIGUSR1); + assert_eq!(pair[worker].attempt(&handled), Outcome::GotThrough); + assert_eq!(pair[worker].attempt("ping"), Outcome::GotThrough); + } + }), + ("a_tcp_connection_is_refused", || { + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + let port = listener.local_addr().unwrap().port(); + refused_only_when_confined(|_| format!("tcp {port}")); + }), + ("a_udp_datagram_is_refused", || { + let socket = UdpSocket::bind("127.0.0.1:0").unwrap(); + let port = socket.local_addr().unwrap().port(); + refused_only_when_confined(|_| format!("udp {port}")); + }), + ("running_a_program_is_refused", || { + refused_only_when_confined(|_| "exec".into()); + }), + ("signalling_another_process_is_refused", || { + // Signal 0 only asks whether the signal may be sent. + refused_only_when_confined(|t| format!("signal {} 0", t.other_pid)); + refused(|t| format!("signal {} {}", t.other_pid, libc::SIGKILL)); + refused(|t| format!("signal {} {}", t.supervisor_pid, libc::SIGKILL)); + // Its process group, which holds the supervisor. + refused(|_| format!("signal 0 {}", libc::SIGKILL)); + }), + ("signalling_itself_works", || { + for attacker in 0..2 { + let mut pair = [StandIn::start(CONFINED), StandIn::start(CONFINED)]; + let pid = pair[attacker].pid; + assert_eq!( + pair[attacker].attempt(&format!("signal {pid} 0")), + Outcome::GotThrough + ); + assert_eq!( + pair[attacker].attempt(&format!("signal {pid} {}", libc::SIGTERM)), + Outcome::Killed(libc::SIGTERM) + ); + assert_eq!(pair[1 - attacker].attempt("ping"), Outcome::GotThrough); + } + }), + ("a_forbidden_system_call_kills_it_with_sigsys", || { + each_of_two( + CONFINED, + |_| "trace-me".into(), + |o| *o == Outcome::Killed(libc::SIGSYS), + "death by SIGSYS", + ); + }), + #[cfg(target_arch = "x86_64")] + ("a_system_call_in_the_x32_range_kills_it", || { + each_of_two( + CONFINED, + |_| "x32".into(), + |o| *o == Outcome::Killed(libc::SIGSYS), + "death by SIGSYS", + ); + }), + #[cfg(target_arch = "x86_64")] + ("a_system_call_from_a_foreign_architecture_kills_it", || { + // A kernel without the 32-bit entry point answers it with SIGSEGV, + // and has no foreign architecture to call by. + if StandIn::start(UNCONFINED).attempt("i386") == Outcome::Killed(libc::SIGSEGV) { + println!(" this kernel has no i386 entry point: nothing to refuse"); + return; + } + each_of_two( + CONFINED, + |_| "i386".into(), + |o| *o == Outcome::Killed(libc::SIGSYS), + "death by SIGSYS", + ); + }), + ]; +} diff --git a/docs/adr/0001-filter-sandbox-for-hosts-without-namespaces.md b/docs/adr/0001-filter-sandbox-for-hosts-without-namespaces.md new file mode 100644 index 0000000..3c2ad99 --- /dev/null +++ b/docs/adr/0001-filter-sandbox-for-hosts-without-namespaces.md @@ -0,0 +1,40 @@ +--- +status: accepted +date: 2026-11-19 +supersedes: none +--- + +# A filter sandbox for hosts without namespaces + +The per-grant isolation contract in the design record asks for grant workers isolated "by user principal/container or equivalent OS sandbox, including between concurrent users". v0.2.0 meets it only with bubblewrap, which needs unprivileged user namespaces. ECS Fargate refuses those to every task (#18), and AWS has said it has no plans to allow it. We add a second worker sandbox, the **filter sandbox**, and define it as the equivalent OS sandbox for hosts that cannot create namespaces. + +## Decision + +1. **Every grant worker gets the same base layers**, in both worker sandboxes: + - a seccomp allow-list of the system calls a grant worker needs once it holds its streams; + - Landlock, at whatever ABI the kernel offers. It is a backstop: the Gateway logs the ABI it got and still starts without Landlock; + - non-dumpable, so no other process of the same user can read its memory; + - no inherited descriptors, environment or secret address space. +2. **The namespace sandbox** adds namespaces on top: the worker's own filesystem, process and network view, supplied by bubblewrap. It stays the default and the recommendation wherever the host allows it. +3. **The filter sandbox** is the base layers alone. It is allowed in sidecar and shared mode, because the base layers keep concurrent users' grant workers apart. +4. **The operator chooses explicitly**: Gateway field `worker_sandbox`, `"namespaces"` (default) or `"filter"`. The Gateway never falls back from one to the other. Startup probes the chosen sandbox and fails closed. The error names the sandbox and the layer that failed, and points to the operator guide rather than suggesting the other sandbox. +5. **A system call outside the allow-list kills the grant worker.** The supervisor logs the cause and fences the grant like any other worker failure, so the grant needs fresh approval. +6. **A grant worker may signal only itself.** Without a PID namespace, every grant worker runs as the same user as the other workers and the supervisor, so the allow-list checks each signal's target. + +## Evidence + +A throwaway probe confined a stand-in worker, handed it a stream by `SCM_RIGHTS` as the Gateway does, and tried what a compromised worker would try. On Fargate 1.4.0 (kernel 6.1.190, x86-64 and arm64, Gateway and Amazon Linux 2023 images), bubblewrap was refused. A task-installed seccomp filter blocked files, the supervisor's environment and memory, other workers' memory, TCP, UDP and running programs, and the stream handoff kept working. Landlock was ABI v2, which covers files and running programs but not the network. [Probe and results](https://github.com/zeroae/countersign/tree/8ab4a7f2f5214eb6439e0d40de5b0fbc0fd24ae5/crates/countersign-gateway/prototype-isolation-probe) ยท [Fargate capability research](https://github.com/zeroae/countersign/blob/8ab4a7f2f5214eb6439e0d40de5b0fbc0fd24ae5/crates/countersign-gateway/prototype-isolation-probe/research-fargate-capabilities.md) + +## Considered options + +- **Fall back automatically** from the namespace sandbox to the filter sandbox. Rejected: a kernel or container-profile change would quietly weaken isolation on every grant worker. +- **A separate user per grant worker.** Rejected: switching users needs a root-started supervisor, against the operator guide's "keep the supervisor unprivileged", and Fargate refuses it anyway. +- **Landlock as the main mechanism.** Rejected: Fargate's ABI v2 does not cover the network, and no ABI covers UDP. +- **A separate Fargate task per grant.** Rejected for now: the handoff passes descriptors, so a remote worker would need a new authenticated transport. +- **Return an error on a forbidden call** instead of killing the worker. Rejected: a grant worker never needs one, so hitting one is a bug or an attack, and either should end the grant. + +## Consequences + +- The filter sandbox gives up the namespace layer. The operator guide and configuration reference say so, and the design record's platform line changes from "requires bubblewrap and unprivileged user namespaces" to name both worker sandboxes. +- The allow-list now runs on every deployment, so a system call a grant worker newly needs (a dependency update, a new libc) kills workers everywhere until it is added. Tests must exercise the real worker under the filter. +- Fargate joins the tested platforms only after a real run with two concurrent grants, in which a paired Companion approves a client certificate and the mock MCP tool reads the mTLS-protected flag. diff --git a/mkdocs.yml b/mkdocs.yml index 32bda9b..c26918a 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -62,6 +62,7 @@ markdown_extensions: - toc: permalink: true exclude_docs: | + /adr/ /agents/ /specs/ /assets/screenshots/raw/