Skip to main content
Version: Development

Supply chain and container hardening

This page describes the provenance, pinning, auditing and least-privilege controls shipped with the distribution. They are checked by python3 scripts/do-prechecks.py; none of them qualifies an image for publication on its own.

Build provenance (source contents, not just HEAD)​

A revision label alone is not provenance: a dirty working tree built after an edit would still carry the HEAD SHA. Every first-party image therefore records a content identity at build time:

Image labelMeaning
org.opencontainers.image.revisionGit commit the build was based on
io.melodee.source.revisionSame commit, recorded by the build tool
io.melodee.source.dirtytrue when tracked/untracked non-ignored files differ
io.melodee.source.sha256SHA-256 over the sorted paths and bytes of the exact working tree

Build and verify one component:

# Candidate/release policy: a dirty or unidentified tree is rejected before the build.
python3 scripts/provenance.py build api --candidate --tag melodee-api:candidate \
--manifest /tmp/melodee-api.json
python3 scripts/provenance.py verify --manifest /tmp/melodee-api.json --require-clean

# Development: dirty inputs are allowed but explicitly recorded.
python3 scripts/provenance.py build admin-ui --tag melodee-supply/admin-ui:local \
--manifest dev/admin-ui-build-manifest.json
python3 scripts/provenance.py verify --manifest dev/admin-ui-build-manifest.json --served

The tool re-reads the source identity after the Docker build and refuses the image if the tree changed during the build, so an image cannot be labelled with one source state while containing another. verify --served reads the served version.json from a UI image and requires its sourceRevision to match the manifest, so relabelling an old image is not enough to pass.

./scripts/dev build records the same identity in dev/build-manifest.json. ./scripts/dev status and a re-up warn when the images on disk were built from different source contents than the current tree. A candidate build rejects dirty inputs; a development build is marked dirty in both the manifest and the image.

The manifest also records the Dockerfile FROM inputs, the authoritative OpenAPI artifact hash and the locks used. Byte-identical rebuilds are not claimed: OS package mirrors and build timestamps are not frozen.

Immutable base images​

Every first-party FROM names a readable tag and a multi-arch index digest:

# node:22.23.1-alpine index (linux/amd64, linux/arm64) resolved 2026-12-02
FROM node:22.23.1-alpine@sha256:16e22a...

Update path (a reviewed dependency change, not an automatic refresh):

python3 scripts/base-images.py --check # offline: every FROM is pinned and commented
python3 scripts/base-images.py --resolve # show current registry digests
python3 scripts/base-images.py --check-remote # fail if a tag moved since the pin
python3 scripts/base-images.py --write # rewrite pins, platforms verified

--write only records digests it actually resolved and requires both supported platforms (linux/amd64, linux/arm64). Review the digest/date diff, then rerun the affected component gates and the root gate.

GitHub Actions and CI​

scripts/ci-hardening.py (run by the root gate) fails when:

  • an action resolves through a mutable tag instead of a full 40-character SHA with a # vX.Y.Z reviewable-version comment;
  • actions/checkout keeps persisted Git credentials in an ordinary job;
  • a build/test job requests write permissions, or a workflow omits explicit permissions/uses pull_request_target;
  • the CI PostgreSQL service is not the distribution major from versions.lock.json (currently 17) or is not digest-pinned.

Ordinary build/test jobs have contents: read only. The only write scopes are the Pages deploy job (pages: write, id-token: write). Updating an action is a reviewed diff of the SHA and its version comment.

Dependency advisories​

python3 scripts/node-audit.py # admin-ui, auth-ui, website
python3 scripts/node-audit.py auth-ui --report /tmp/audit.json

The gate reads the committed lockfile with npm audit --json, records Node/npm versions, the UTC date and SHA-256 of package.json/package-lock.json, and fails on actionable findings. Scanner or registry failures are failures, never "clean"; npm audit fix/--force is never run. Per-target severity policy and reviewed exceptions live in config/node-audit-policy.json. Exceptions must name the advisory, package, expiry and justification, and an expired or stale exception fails the gate.

Both UI CI workflows run the scan; the website runs it inside npm run prechecks. The latest website recheck, its lock hash and exposure classification are in design/evidence/website/audit-2026-12-02.md.

Container least privilege​

ContainerIdentityFilesystemCapabilities
proxy (edge)root master, nginx workersread-only root + tmpfs (/tmp, /run, /etc/nginx/conf.d, /var/cache/nginx)cap_drop: ALL; only CHOWN, DAC_OVERRIDE, NET_BIND_SERVICE, SETGID, SETUID
auth-ui, admin-ui101:101 (nginx)read-only root + tmpfs as abovecap_drop: ALL, no-new-privileges
api, schema-check, climelodeeread-only root; private state volume, media binds and /tmp writablecap_drop: ALL

The edge master keeps root only to read the operator's 0600 TLS key and bind the privileged port; workers run unprivileged. The UIs listen on unprivileged ports and need only the writable tmpfs paths nginx creates at startup. Media storage, the private API volume and the CLI workspace stay writable through their mounts. docker compose config -q validates both topologies, and the dev stack is the executable check for the same settings.

Edge logs and forwarded metadata​

The edge logs only 4xx/5xx with a route class (never the raw path or query string), status, request/upstream timing, upstream status, nginx $request_id and host. Share tokens live in path segments, so paths are collapsed to /share, /auth, /api, /admin, /ui-assets, etc. The same request id is returned in the X-Request-Id response header and forwarded to the API; client-supplied values are replaced. Docker logging rotation bounds retention (10m x 3 per service).

X-Forwarded-Port is derived from the trusted listen port ($server_port: 443 production, the configured development edge port, normally 8443), never a hard-coded value or a client header. X-Forwarded-For, X-Forwarded-Proto, X-Forwarded-Host and Origin/Sec-Fetch-* are likewise owned by the edge.

Credential-bearing /api/v1/auth/ requests also pass a per-source edge rate/burst ceiling (120r/m, burst=60, 429 on excess) as defence in depth; the API keeps its own admission budgets. Unknown routes never fall back to a UI, and redirects are emitted relative (absolute_redirect off) so an internal container port cannot leak into Location.

The Auth UI response policy (CSP, COOP, CORP, Referrer-Policy, Permissions-Policy and the remaining headers) is vendored in config/auth-ui/security-headers.conf and must match the Auth UI's authoritative policy. The root gate starts both the release and development Auth UI listeners and fails if any required header is missing on a 200, 404 or error response. Google Identity Services origins are the only external allowance; passkeys remain available because publickey-credentials-get is deliberately unrestricted.

Liveness, readiness and diagnostics​

/healthz is process liveness only; /readyz reports PostgreSQL and writable Storage Volume readiness. The API/Docker health check uses /healthz, the edge starts independently of API readiness, and a missing volume does not stop the process or trigger a restart loop. The static Auth/Admin UIs stay reachable so the setup or "temporarily unavailable" surface and the readiness JSON can be inspected. Restoring storage is picked up by the next readiness probe; no local fallback is created.