fix(worker): second security pass — content-only rejection codes (resource_limit, explicit list), negative proofs of the seccomp argument filters, PR_GET_DUMPABLE self-check, strict WebP chunk structure, iCCP-bomb fixture, separate test target cache; ci: release-images builder actually used (job-level DOCKER_CONFIG, --builder), literal cleanup path, token scoped to the login step, npm advisories gate, digests from build metadata

This commit is contained in:
bchanot committed 2026-10-13 00:36:30 +02:00
1 parent 11813f5560
commit a8b644a515
12 files changed
+278 -55

No files matched your search

+42 -20
View File
@@ -4,13 +4,17 @@
# a validation. Nothing here deploys; DEPLOY.md "Image deploy by digest (prepared at R0, not
# yet applied)" is the runbook.
#
# Hardening (security audit of R0): the dispatch input is a typed choice re-validated in
# the shell through an environment variable (never interpolated into a script); secrets
# reach the shell through env only, the registry login lives in a per-job DOCKER_CONFIG
# removed at the end; images are built by an ephemeral buildx builder with its own cache,
# so nothing a PR build left in the daemon's cache mounts or volumes can reach a release
# image; the RustSec advisories gate runs before any push; only main and develop may be
# released; the checkout action is pinned to a commit.
# Hardening (security audits of R0): the dispatch input is a typed choice re-validated in
# the shell through an environment variable (never interpolated into a script); the registry
# token reaches the login step only, through env, into a per-job DOCKER_CONFIG under
# RUNNER_TEMP created before any step and removed by a literal path; the images are built by
# a named ephemeral buildx builder (`--builder`, so a missing builder fails instead of
# falling back to the daemon's shared BuildKit and its cache mounts); the RustSec and npm
# advisories gates run before any push; `actions/checkout` is pinned to a commit. The
# `if: github.ref` line keeps honest runs on main or develop: it is not a security boundary
# (whoever can push a branch can dispatch a copy of this file), push access and the token's
# scope are. The real isolation from pull-request jobs is a dedicated release runner label
# that never runs them (Step 27 operations).
#
# Secrets expected on the forge: REGISTRY (host, e.g. the Gitea container registry of this
# forge), REGISTRY_USER, REGISTRY_TOKEN (write:package scope). Images are pushed as
@@ -37,11 +41,14 @@ jobs:
env:
SHEET_BUNDLE: ${{ inputs.sheet_bundle }}
REGISTRY: ${{ secrets.REGISTRY }}
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
NAMESPACE: ${{ github.repository_owner }}
GIT_SHA: ${{ github.sha }}
# Per-job Docker config, set before any step runs: the login and the builder live here.
DOCKER_CONFIG: ${{ runner.temp }}/faunosteo-release-docker
BUILDER: faunosteo_release_${{ github.sha }}
steps:
- name: Per-job Docker config directory
run: mkdir -m 700 -p "$DOCKER_CONFIG"
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Validate the dispatch input (the shell trusts the env value only after this)
run: |
@@ -53,25 +60,40 @@ jobs:
run: |
docker build -f docker/rust-builder.Dockerfile -t faunosteo_rust_builder:1.99.0 docker
bash docker/rust-run.sh cargo deny check advisories
- name: Ephemeral builder with its own cache and a per-job Docker config
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
- name: npm advisories gate for the application image (production dependencies)
run: |
echo "DOCKER_CONFIG=$(mktemp -d)" >> "$GITHUB_ENV"
docker buildx create --name "faunosteo_release_$GIT_SHA" --driver docker-container --use
- name: Registry login (token from env, never on the command line)
corepack enable && corepack prepare --activate
pnpm install --frozen-lockfile
pnpm audit --prod --audit-level=high
- name: Ephemeral builder with its own cache (named; every build names it explicitly)
run: docker buildx create --name "$BUILDER" --driver docker-container
- name: Registry login (token in this step's env only, never on the command line)
env:
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: printf '%s' "$REGISTRY_TOKEN" | docker login "$REGISTRY" -u "$REGISTRY_USER" --password-stdin
- name: Build and push the application image
run: |
image="$REGISTRY/$NAMESPACE/faunosteo_app:$GIT_SHA"
docker buildx build --push --provenance=false --build-arg "SHEET_BUNDLE=$SHEET_BUNDLE" -t "$image" .
echo "app: $(docker buildx imagetools inspect "$image" --format '{{json .Manifest.Digest}}')" >> "$GITHUB_STEP_SUMMARY"
docker buildx build --builder "$BUILDER" --push --provenance=false \
--metadata-file "$RUNNER_TEMP/app-metadata.json" \
--build-arg "SHEET_BUNDLE=$SHEET_BUNDLE" -t "$image" .
digest="$(sed -n 's/.*"containerimage.digest": *"\([^"]*\)".*/\1/p' "$RUNNER_TEMP/app-metadata.json")"
echo "app: $image@$digest" >> "$GITHUB_STEP_SUMMARY"
- name: Build and push the worker image
run: |
image="$REGISTRY/$NAMESPACE/faunosteo_worker:$GIT_SHA"
docker buildx build --push --provenance=false -f crates/worker/Dockerfile -t "$image" .
echo "worker: $(docker buildx imagetools inspect "$image" --format '{{json .Manifest.Digest}}')" >> "$GITHUB_STEP_SUMMARY"
- name: Logout, remove the builder and the per-job Docker config
docker buildx build --builder "$BUILDER" --push --provenance=false \
--metadata-file "$RUNNER_TEMP/worker-metadata.json" \
-f crates/worker/Dockerfile -t "$image" .
digest="$(sed -n 's/.*"containerimage.digest": *"\([^"]*\)".*/\1/p' "$RUNNER_TEMP/worker-metadata.json")"
echo "worker: $image@$digest" >> "$GITHUB_STEP_SUMMARY"
- name: Logout, remove the builder and the per-job Docker config (literal path)
if: always()
run: |
docker logout "$REGISTRY" || true
docker buildx rm "faunosteo_release_$GIT_SHA" || true
rm -rf "$DOCKER_CONFIG"
docker buildx rm "$BUILDER"
rm -rf -- "${RUNNER_TEMP:?}/faunosteo-release-docker"