feat(worker): V1-2.3 sandboxed verify child and sheet-verify job mode
This commit is contained in:
1 parent
345dde59e6
commit
31fbb0317f
24 files changed
+2145
-87
No files matched your search
@@ -1,30 +1,38 @@
|
||||
#!/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.
|
||||
# Derives the seccomp allowlist of the decode and verify children 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.
|
||||
# The verify child (V1-2.3) shares the filter: its framed fixtures (a small sheet and the
|
||||
# sheet at every cap) are traced the same way.
|
||||
#
|
||||
# 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).
|
||||
# legitimate decode or verification). Syscalls the list allows but the trace never shows are
|
||||
# printed for review (the abort path is expected there).
|
||||
set -eu
|
||||
|
||||
bin=target/release/faunosteo-worker
|
||||
cargo build -p faunosteo-worker --release --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"
|
||||
# trace <command> <fixture>: one child run, the syscalls after the marker appended.
|
||||
trace() {
|
||||
"$bin" fixture "$2" > "$work/$2.bin"
|
||||
# `env -i`: the child refuses a non-empty environment; `--no-seccomp` keeps the rlimits
|
||||
# and makes one sched_yield where the filter would be installed (strace cannot read the
|
||||
# child's memory once PR_SET_DUMPABLE is 0, so the marker is a syscall, not a string).
|
||||
env -i strace -f -qq -o "$work/trace.$kind" "$bin" decode --no-seccomp \
|
||||
< "$work/$kind.bin" > "$work/$kind.webp"
|
||||
awk 'found { print } /sched_yield\(/ { found = 1 }' "$work/trace.$kind" \
|
||||
env -i strace -f -qq -o "$work/trace.$2" "$bin" "$1" --no-seccomp \
|
||||
< "$work/$2.bin" > "$work/$2.out"
|
||||
awk 'found { print } /sched_yield\(/ { found = 1 }' "$work/trace.$2" \
|
||||
| sed -E 's/^[0-9]+ +//; /^(\+\+\+|---)/d; s/^<\.\.\. ([a-z0-9_]+) resumed>.*/\1/; s/\(.*//' \
|
||||
| grep -E '^[a-z0-9_]+$' >> "$work/traced.raw" || true
|
||||
}
|
||||
for kind in png jpeg webp big-jpeg big-png; do
|
||||
trace decode "$kind"
|
||||
done
|
||||
for kind in verify-clean verify-caps; do
|
||||
trace verify "$kind"
|
||||
done
|
||||
sort -u "$work/traced.raw" > "$work/traced.txt"
|
||||
"$bin" print-allowlist | sort -u > "$work/allowed.txt"
|
||||
@@ -41,7 +49,7 @@ 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 "== TRACED BUT NOT ALLOWED (the filter would kill a legitimate decode or verification):"
|
||||
echo "$missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user