feat(worker): sandboxed decode child skeleton — rlimits, traced seccomp allowlist, pure-Rust decoders, libwebp in the child, parent RIFF check, musl image with test stage
This commit is contained in:
1 parent
2a38fa37b5
commit
3970cdca52
13 files changed
+1435
No files matched your search
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# Derives the seccomp allowlist of the decode child from a real trace and checks it against
|
||||
# `sandbox::ALLOWED_SYSCALLS` (review Part IV.1: "derived by strace over the fixture corpus
|
||||
# at the caps on the production image, not hand-written"). Runs in the Alpine `test` stage
|
||||
# of crates/worker/Dockerfile, where the musl binary that ships is built.
|
||||
#
|
||||
# Exit 1 when a traced syscall is missing from the allowlist (the sandbox would kill a
|
||||
# legitimate decode). Syscalls the list allows but the trace never shows are printed for
|
||||
# review (the abort path is expected there).
|
||||
set -eu
|
||||
|
||||
bin=target/debug/faunosteo-worker
|
||||
cargo build -p faunosteo-worker --features test-hooks --locked
|
||||
work=$(mktemp -d)
|
||||
|
||||
fixtures="png jpeg webp big-jpeg big-png"
|
||||
: > "$work/traced.raw"
|
||||
for kind in $fixtures; do
|
||||
"$bin" fixture "$kind" > "$work/$kind.bin"
|
||||
# `env -i`: the child refuses a non-empty environment; `--no-seccomp` keeps the rlimits
|
||||
# and prints the marker where the filter would be installed.
|
||||
env -i strace -f -qq -o "$work/trace.$kind" "$bin" decode --no-seccomp \
|
||||
< "$work/$kind.bin" > "$work/$kind.webp"
|
||||
awk 'found { print } /SECCOMP-MARKER/ { found = 1 }' "$work/trace.$kind" \
|
||||
| sed -E 's/^[0-9]+ +//; /^(\+\+\+|---)/d; s/^<\.\.\. ([a-z0-9_]+) resumed>.*/\1/; s/\(.*//' \
|
||||
| grep -E '^[a-z0-9_]+$' >> "$work/traced.raw" || true
|
||||
done
|
||||
sort -u "$work/traced.raw" > "$work/traced.txt"
|
||||
"$bin" print-allowlist | sort -u > "$work/allowed.txt"
|
||||
|
||||
echo "== syscalls traced after the sandbox marker"
|
||||
cat "$work/traced.txt"
|
||||
missing=$(comm -23 "$work/traced.txt" "$work/allowed.txt")
|
||||
extra=$(comm -13 "$work/traced.txt" "$work/allowed.txt")
|
||||
echo "== allowed but not traced (abort path expected): $(echo "$extra" | tr '\n' ' ')"
|
||||
if [ -n "$missing" ]; then
|
||||
echo "== TRACED BUT NOT ALLOWED (the filter would kill a legitimate decode):"
|
||||
echo "$missing"
|
||||
exit 1
|
||||
fi
|
||||
echo "== allowlist covers the trace"
|
||||
Reference in new issue
Block a user