Skip to content

Check Compose projects against a list of allowed settings - #136

Merged
tricknotes merged 1 commit into
mainfrom
policy-allowlist
Nov 23, 2026
Merged

tricknotes merged 1 commit into
mainfrom
policy-allowlist

Conversation

@tricknotes

Copy link
Copy Markdown
Owner

Summary

The policy check judged the settings it knew to be dangerous and let every other setting through. Compose has many more, and several reach the host or another app just as well. Deployed through the engine with a real Docker and Compose, without the relax flag, each of these worked:

Setting What happened
a provider service a script of the repository ran on the host, as the user koroku runs as
use_api_socket: true the Docker socket was mounted into the container
a volume with driver_opts of type overlay host directories were readable in the container
build.entitlements: [network.host], build.ssh RUN steps got the host network; a host key file was handed to the build
a post_start hook with privileged: true the hook ran with every capability
network_mode: <another app's network> the container reached that app's services
build.tags the image was named like another app's image
include with env_file another app's variables ended up in this app's containers
a relative build.dockerfile with .. a host file's first line was printed into the deployment log

What changes:

  • A list of allowed settings. The normalized project is compared with the settings koroku allows (internal/compose/schema.go); anything else is refused under the new rule unsupported_setting, so a setting nobody has looked at does not pass.
  • Values of allowed settings. network_mode, pid/ipc/uts/userns_mode/cgroup, security_opt (only no-new-privileges), volume driver options (only nfs, nfs4, tmpfs), mount types, volume/network/logging drivers, local build caches, and the Dockerfile path resolved against its context. A service without build may not name an image koroku built for another app (foreign_image).
  • include and extends.file are resolved while Compose loads the files and leave nothing in the normalized project, so koroku reads the files itself before Compose does: only plain paths to files inside the checkout, no env_file or project_directory, no Git or OCI addresses. That needs a YAML parser; go.yaml.in/yaml/v3 is added (the standard library has none, and a text search misses keys written with quotes, escapes or anchors).
  • Revalidation under the conditions of the start. A release that is started again (start, rollback, one-off commands) was checked without the app's DOCKER_CONFIG and with the env file of whatever release was running; Compose interpolates ${VAR} from both, so a file could describe one project to the check and another to up. The check now uses the release's own env snapshot and the DOCKER_CONFIG of the command that follows, and Compose gets only the part of koroku's environment it needs to run.
  • A failed pull no longer removes images that a release of another app was built as.

Every new rule can be waived with the app's relax flag, like the other rules that protect the host. build.tags is refused rather than silently reset, so that the error names the setting.

ARCHITECTURE 6 and 10, the prepare-app requirements and the deploy-status Skill describe the rules; the plugin version goes to 0.26.0.

Test plan

  • go vet ./..., go vet -tags integration ./..., go test ./...
  • Golden files from a real docker compose config (Compose v5.8.0): escape (every service must be blocked) and allowed (ordinary settings, only the published port is reported)
  • Integration: TestPolicyBlocksWaysOut deploys 13 such repositories through the engine; each fails at validation, nothing runs, no host file content reaches the log
  • Integration: TestComposePrintsOnlyAllowedSettingsForOrdinaryFiles runs the local Compose over the ordinary file, to catch a Compose release that renames or adds settings
  • The whole integration suite on the combined stack
  • The seven apps of a running instance were checked against the new rules beforehand (merged configuration and repository Compose files): none is refused

🤖 Generated with Claude Code

The policy check judged the settings it knew to be dangerous and let
every other setting through. Compose has many more, and several reach
the host or another app just as well. Deployed through the engine with a
real Docker and Compose, without the relax flag:

- a `provider` service ran a script of the repository on the host, as
  the user koroku runs as;
- `use_api_socket: true` mounted the Docker socket into the container;
- a volume with `driver_opts` of type overlay read host directories;
- `build.entitlements: [network.host]` gave RUN steps the host network,
  and `build.ssh` handed a host key file to the build;
- a `post_start` hook with `privileged: true` ran with every capability;
- `network_mode: <another app's network>` reached that app's services;
- `build.tags` named the image like another app's image;
- an `include` with `env_file` put another app's variables into this
  app's containers;
- a relative `build.dockerfile` with `..` printed a host file's first
  line into the deployment log.

The normalized project is now compared with a list of the settings
koroku allows (internal/compose/schema.go); anything else is refused
under the rule `unsupported_setting`, so a setting nobody has looked at
does not pass. Settings on the list whose value matters are judged by
value: network_mode, pid/ipc/uts/userns_mode/cgroup, security_opt (only
no-new-privileges), volume driver options (only nfs, nfs4, tmpfs), mount
types, volume/network/logging drivers, local build caches, and the
Dockerfile path resolved against its context. A service without `build`
may not name an image koroku built for another app (`foreign_image`),
and a failed pull no longer removes images that a release of another
app was built as.

`include` and `extends.file` are resolved while Compose loads the files
and leave nothing in the normalized project, so koroku reads the files
itself before Compose does: only plain paths to files inside the
checkout, no `env_file` or `project_directory`, no Git or OCI addresses.
That needs a YAML parser. The standard library has none, and a text
search misses keys written with quotes, escapes or anchors, so
go.yaml.in/yaml/v3 is added.

A release that is started again (start, rollback, one-off commands) was
checked with other conditions than the `up` that followed: without the
app's DOCKER_CONFIG and with the env file of whatever release was
running. Compose interpolates `${VAR}` from both, so a file could
describe one project to the check and another to `up`. The check now
uses the release's own env snapshot and the DOCKER_CONFIG of the command
that follows, and Compose gets only the part of koroku's environment it
needs to run.

Every new rule can be waived with the app's relax flag, like the other
rules that protect the host. The seven apps of a running instance were
checked against the new rules beforehand: none is refused.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@tricknotes
tricknotes deleted the branch audit-small-fixes November 23, 2026 19:22
@tricknotes tricknotes closed this Nov 23, 2026
@tricknotes tricknotes reopened this Nov 23, 2026
@tricknotes
tricknotes changed the base branch from audit-small-fixes to main November 23, 2026 19:23
@tricknotes
tricknotes merged commit 6502570 into main Nov 23, 2026
10 checks passed
@tricknotes
tricknotes deleted the policy-allowlist branch November 23, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant