Dockerfile and Compose Security
Blocks on an agent's file writes and at turn end.
Acts on
File write · Turn end
When
Before the file write · at turn end
Tested
37 of 37 pass
In a git repo
At commit
What it does
Blocks (some rules ask) when a change to a Dockerfile, Containerfile or compose file adds: a base image with no tag, a floating tag (latest, stable, edge, lts) or an unresolvable ARG; a final stage running as root; TLS or signature checks off; secret ENV/ARG/environment literals; COPY of key or .env files; remote ADD without checksum; fetch piped to a shell; RUN --security=insecure; chmod 777 or setuid; sudo, sshd, chpasswd; unpinned git clone; ONBUILD RUN; compose privileged, broad cap_add, unconfined profiles, devices, host namespaces, runtime socket or host-root mounts, DB ports on every interface. A one-line form goes to block-fetch-exec-in-files, block-unpinned-agent-components or agentic-code-security only where that gate is installed and reads the file; scan-secrets lines always. Misses: digest pinning (a version tag passes), build args overriding defaults, commands in variables, aliases or $'' quoting, bake and k8s files, extends or include, other file names, a moved file. Friction, not a boundary.
Chock adds friction. It is not a security boundary.
Its label on each agent
The catalog grades each policy on each agent. Pick an agent to build with this policy:
- Claude Code TestedBlocks Blocks on an agent's file writes and at turn endBuild →
- Cursor TestedBlocks Blocks on an agent's file writes and at turn end. Where its description says it asks, it refuses at both points, because this client cannot prompt at either pointBuild →
- Codex TestedBlocks Blocks on an agent's file writes and at turn end. Where its description says it asks, it refuses at both points, because this client cannot prompt at either point. If the hook errors, the action goes through (not witnessed; the vendor's row is only partly live-run)Build →
- GitHub Copilot TestedBlocks Blocks at turn end only. It does not check a file write when it happens. Where its description says it asks, it refuses at turn end, because this client cannot prompt there. If the hook errors, the action goes through (not witnessed; the vendor's row is only partly live-run)Build →
- Devin TestedBlocks Blocks at turn end only. It does not check a file write when it happens. Where its description says it asks, it refuses at turn end, because this client cannot prompt there. If the hook errors, the action goes through (vendor docs only, not witnessed)Build →
- Grok Tested Not graded yet for GrokBuild →
- goose Tested Not graded yet for gooseBuild →
- Antigravity Tested Not graded yet for AntigravityBuild →
- OpenHands Untested Not graded yet for OpenHandsBuild →
- Kimi Code Untested Not graded yet for Kimi CodeBuild →
- Factory Droid Untested Not graded yet for Factory DroidBuild →
See it in action
Refused
A commit adds a Dockerfile whose only stage is built FROM an untagged image.
Allowed
A commit adds a Dockerfile pinned by digest, built FROM an earlier stage, running as a non-root user.
Both examples are this policy's own test cases.
What it misses
Digest pinning (a version tag passes), build args overriding defaults, commands in variables, aliases or $'' quoting, bake and k8s files, extends or include, other file names, a moved file.
Latest change
0.2.1 · · Hardening from the infra review (org-plan witness/reviews/2026-11-15-policy-hardening/REVIEW-infra.md, section 2.1 and 3; tests in test_dockerfile_compose_review.py). Behaviour change: a person's # chock: allow <rule-id> is honoured at push and ci as at commit (it was commit only, so a reviewed exception passed the hook and failed the pipeline); an agent's commit, write and the turn's end still refuse it. Behaviour change: the rules dk-from-no-digest and cm-image-no-digest are removed. They asked on the commonest correct image reference (a version tag without a digest), the gate has no warn tier for a script finding, and floating images are already caught by dk-from-floating and cm-image-floating, so nothing they caught is lost; pinning by digest is no longer checked, and the prose says so. Which tags float is data (dkscan/data/floating-tags.json): a tag floats when any of its -._ components is a floating word (latest, stable, edge, lts, mainline and the like, so lts-alpine and stable-slim float), or when it holds no digit and does not start with a Debian or Ubuntu release codename (python:slim, golang:alpine float; debian:bookworm-slim does not); a tag with a digit and no floating component is a version (node:20, postgres:16.4). A # chock: allow dk-from-no-digest already in a file is now unused and harmless. Behaviour change: a compose file that cannot be read now refuses what a change adds even when HEAD's copy was unreadable too (cm-unreadable is new on every write, as in ci-github-actions-security); editing a compose file that stays unreadable is refused until it is fixed. Behaviour change: a compose finding is keyed without its service name, so renaming a service no longer re-fires the findings it already held; a second service with the same weakness is still new, but a weakness moved from one service to another is not (the counts match). Known limits: a moved file still re-fires its findings (engine, E-1); the scope is still by file name.