fix(worker): iCCP-bomb proof asserts the content-rejection property (either content code); docs(docs): RUST.md worker and release workflow wording after the second security pass

This commit is contained in:
bchanot committed 2026-10-13 00:37:33 +02:00
1 parent a8b644a515
commit 3af2861be7
3 files changed
+46 -25

No files matched your search

+32 -19
View File
@@ -100,18 +100,25 @@ sandbox in a single-threaded process:
`image::Limits` (sides ≤ 4096, alloc 256 MiB), applies the EXIF
orientation, `resize_to_fill` 512 × 512, encodes lossy WebP (q 82) through
`libwebp-sys` (C, this process only), writes stdout. Exit codes in
`exit_codes.rs` (10–18, never 1, 101 or a signal number).
`exit_codes.rs` (10–19, never 1, 101 or a signal number); every decode-time
error maps to a content code (`unsupported_type`, `decode_failed`,
`dimensions`, `resource_limit`), so no upload can produce a broken-environment
code.
- the parent side (`spawn::Spawner`, used by the tests now and by R1):
`env_clear`, stdin/stdout/stderr piped, output read up to 512 KiB (the
child is killed past it), 20 s deadline, classification of every exit
(`Produced`, `Rejected{code}` for the content codes 12 to 17,
`Broken{code}` when the child could not even start (usage, non-empty
environment, sandbox failure, internal: R1 alerts instead of blaming the
upload), `Signalled{signal}`, `OutputOverflow`, `Timeout`, `Failed`). The
(`Produced`, `Rejected{code}` for the content codes
(`exit_codes::is_content_rejection`, an explicit list), `Broken{code}` when
the child could not run properly (usage, non-empty environment, sandbox
failure, encode or output failure, internal: R1 alerts instead of blaming
the upload; no content can produce it), `Signalled{signal}`,
`OutputOverflow`, `Timeout`, `Failed`). The
parent **never decodes**: `webp_check::inspect` parses the RIFF container
only (chunk allowlist `VP8X`, `VP8 `, `VP8L`, `ALPH`; canvas size from the
headers, the frame size must agree with the canvas; any `EXIF`, `XMP `,
`ICCP` or unknown chunk refuses the output; owner amendment of D-R4). The
only (chunk allowlist `VP8X`, `VP8 `, `VP8L`, `ALPH`; the encoder's structure
enforced: optional `VP8X` first, optional `ALPH` only in an extended file,
exactly one frame; canvas size from the headers, the frame size must agree
with the canvas; any `EXIF`, `XMP `, `ICCP` or unknown chunk refuses the
output; owner amendment of D-R4). The
child's stderr (≤ 4 KiB) is child-controlled text: R1 never logs it raw
(LRN-044).
- `run --check`: prints the resolved configuration without secrets (which
@@ -145,15 +152,18 @@ binary), `run --check` exits 0 with `--read-only --cap-drop ALL
started once with `--read-only --cap-drop ALL`.
- `rust-advisories.yml`: nightly and manual `cargo deny check advisories`,
out of the blocking path on purpose.
- `release-images.yml`: manual only, on `main` or `develop`; the dispatch
input is a typed choice re-validated through an environment variable;
the RustSec advisories gate runs first; an ephemeral `buildx` builder with
its own cache builds the images (nothing a PR build left in the daemon's
cache mounts or volumes can reach a release image); secrets reach the
shell through env only, the login lives in a per-job `DOCKER_CONFIG`
removed at the end; `actions/checkout` pinned to a commit. It pushes
`faunosteo_app:<sha>` and `faunosteo_worker:<sha>` and prints their
digests. Deploys nothing (DEPLOY.md "Image deploy by digest").
- `release-images.yml`: manual only; the dispatch input is a typed choice
re-validated through an environment variable; the RustSec and npm
(`pnpm audit --prod`) advisories gates run first; a named ephemeral
`buildx` builder (`--builder`, no silent fallback) with its own cache
builds the images; the registry token reaches the login step only, into
a per-job `DOCKER_CONFIG` under `RUNNER_TEMP` created before any step and
removed by a literal path; digests read from the build metadata;
`actions/checkout` pinned to a commit. The `if: github.ref` line is not a
boundary (push access and the token's scope are; a dedicated release
runner label is the Step 27 operation). It pushes `faunosteo_app:<sha>`
and `faunosteo_worker:<sha>` and prints their digests. Deploys nothing
(DEPLOY.md "Image deploy by digest").
Not measured here: the forge runner's cache behaviour and cold build times
(the runner was not available from this host). The builder image build took
@@ -214,12 +224,15 @@ static binary.
allowlist is that set plus the abort path (`rt_sigaction`,
`rt_sigprocmask`, `getpid`, `gettid`, `tkill`, `tgkill`, `exit`).
- Proven on the release-profile musl binary with the test hooks, inside
Docker's default seccomp profile: 13 tests green (`png_jpeg_and_webp_decode_through_the_full_sandbox`,
Docker's default seccomp profile: 16 tests green (`png_jpeg_and_webp_decode_through_the_full_sandbox`,
`inputs_at_the_caps_decode_within_the_limits` (4096²), dimensions 32 px
and 20 000² header, GIF and SVG refused, truncated PNG, non-empty
environment refused, `--violate` → SIGSYS 31, `--flood` → output cut,
`--alloc-gib 2` → SIGABRT 6 under `RLIMIT_AS`, `--spin` → parent deadline,
`--spin` → SIGXCPU 24 at the CPU soft limit, libwebp ≥ 1.6.0).
`--spin` → SIGXCPU 24 at the CPU soft limit, libwebp ≥ 1.6.0; negative
proofs of the argument filters: `--signal-parent` (`tkill` to the parent)
and `--mmap-exec` → SIGSYS; an `iCCP` bomb of 300 MB inflated → a content
rejection, never a broken-environment outcome).
- Findings: with `RLIMIT_CPU` soft = hard the kernel sends SIGKILL (hard
limit checked first), indistinguishable from the parent's deadline kill;
the soft limit is now two seconds below the hard one. The 4096² decode