Skip to content

[M3.8a] Fail-closed Compose validator - #195

Merged
samuelmbabhazi merged 1 commit into
mainfrom
feat/m3.8a-compose-validator
Nov 7, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
feat/m3.8a-compose-validator

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

apps/api/src/modules/apps/domain/compose.ts: a pure parser and validator for Compose files, producing typed services. No route reaches it yet. Accepting compose: applications and deploying several services per release are M3.8b and M3.8c, now split out in the PLAN.

Why

PLAN M3.8, and the "Compose injection" row of the threat model.

Design: stricter than the SPEC's list, so the SPEC is updated

It is an allow list that fails closed, not a list of rejected keys. A key is translated to what the agent's typed ContainerSpec can express, ignored with a warning when that has no effect on safety, or refused with its reason. A new Compose key is refused by default.

What the spec's shape settled:

  • All bind mounts are refused, including inside the application's data directory, which the SPEC allowed. ContainerSpec mounts only named volumes and tmpfs. This is the decision most likely to hurt adoption, because many real files use ./data:/data. Allowing them would be an agent action change, which is the owner's call.
  • entrypoint and cap_drop are refused because the spec cannot express them, rather than silently run without them.
  • Health commands never run: the agent probes over HTTP or TCP. A curl or wget on localhost is read for its URL; anything else is dropped with a warning.
  • Ports keep only the container port: nothing is published on the host.
  • ${NAME} expands only in environment. A bare name that would inherit from the host's environment is refused.

How it was tested

compose.spec.ts, 97 tests, 90% line coverage:

  • 15 everyday stacks (WordPress, Nextcloud, Grafana and others), hand-written and adapted to these rules. They are not the published files: the plan's "15 popular files deploy" is not met until M3.8c, and real files may need adapting.
  • Over 70 hostile files, covering every SPEC rule: socket mounts in several disguises, driver options binding the host, YAML merges smuggling privileged, traversal, injected images and users, reserved sk. labels, prototype keys, dependency cycles.
  • No crash and no echo: 500 pseudo-random documents plus deep nesting, alias bombs, oversized input and YAML tags. Parser messages are not forwarded, because they quote the input, which may hold secrets.

Security considerations

  • Pure code with no I/O or process execution. Nothing here runs until M3.8b wires it in.
  • THREAT_MODEL also asks for native Go fuzzing of "the Compose validator", written when the validator's language was undecided. It lives in TypeScript, so that remains open under M10.2; the pseudo-random test above is a smaller stand-in.
  • Over the 500-line PR target, at about 800 lines of validator: it reads as one allow list and splitting it would hide that.

Checklist

  • Domain code is pure, 90% coverage
  • Malicious-input tests
  • No new shell invocation, no new secret exposure path
  • SPEC and PLAN updated

@samuelmbabhazi
samuelmbabhazi merged commit f93ed1b into main Nov 7, 2026
@samuelmbabhazi
samuelmbabhazi deleted the feat/m3.8a-compose-validator branch November 7, 2026 13:11
samuelmbabhazi added a commit that referenced this pull request Nov 7, 2026
## What changed

Rewrites the PLAN's "Next tasks" list, which still named work merged in
#182 to #195. It now groups what remains by what it is waiting on: a VM,
an owner decision, billing, or nothing.

## Why

So the next person, or session, starts from what is true.

## How it was tested

Documentation only. For the record, the final `main` at #195 was run
locally against PostgreSQL 18.4:

- Integration suite: 314 passed, 3 failed. The 3 expect `23503` for `ON
DELETE RESTRICT`, which PostgreSQL 18 reports as `23001`.
- Browser suite: 17 of 17 passed.

## Security considerations

None.

Signed-off-by: review <[email protected]>
Co-authored-by: review <[email protected]>
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