Chock.sh Build your plugin

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, latest, an unresolvable ARG or no digest (stage-aware: FROM or COPY --from a stage is not an image); a final stage running as root; TLS or package-signature checks off; secret-named 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, database ports on every interface, untagged images. A one-line form is left 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: build args overriding defaults, commands in variables, aliases or $'' quoting, bake and k8s files. 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

Build args overriding defaults, commands in variables, aliases or $'' quoting, bake and k8s files.

Latest change

0.2.0 · · Hardening (SR-2d2d; findings F24, F26, F33; eval cases tc-035 to tc-037; tests in test_dockerfile_compose_sr2d2.py). Behaviour change: a sibling gate (block-fetch-exec-in-files, block-unpinned-agent-components, agentic-code-security) counts as installed only when a readable regular gate.json (not a symlink, at most 1 MiB) under its compiled folder, directly or one folder down, has action: block; a bare folder, such as one a plain mkdir leaves, an unreadable file or a gate that only warns no longer hides this bundle's deny findings. Behaviour change: the fetch-exec and remote-ADD deferral applies the installed sibling's own content_pattern from its compiled gate to the physical line, and defers nothing when the pattern is missing or does not compile; the HP03 regex copies are gone, so forms the sibling's pattern reads (a quoted 'curl', a pipe into python3 -) are now left to it and a line it does not read (a space-preceded # in quotes before the fetch) is reported here. Behaviour change: a secret-named literal is left to scan-secrets only when scan-secrets' pattern matches a span of one raw physical line that holds the literal, not a name: value string rebuilt from the parsed value, so an alias, anchor, tag, block or wrapped scalar, or a Dockerfile value split by a continuation, is reported here. Known limits: the copied scan-secrets pattern is still the 0.0.9 one (it reads fewer quoted-colon forms than the shipped 0.1.2, which only means a double report); the pins and node-tls deferrals still use this bundle's own line patterns, gated by the same block-action check. protect-agent-config's mkdir of compiled folders is not changed here.