Deploy follow-ups from the #52 reviews: the rendered checker, the SECURITY record and the CI guard #64

Open
opened 2026-11-15 03:39:05 +00:00 by svc-agent-writer · 0 comments

The correctness review and the security review of PR #63 (head f929a91) found no blocker. The rendered pod deploys safely: each process has its own memory-backed /tmp and its own secret volume, every image is the zero-digest placeholder, and the NetworkPolicy allows only the api port in and the Feeder /32 out. The findings below are in the new checks and the documents. PR #63 cannot take a rework round, because the runner refuses a branch that carries a CI-surface diff, so they land here.

Should fix first

  1. The rendered checker never compares the NetworkPolicy podSelector with the pod labels (tests/rendered_manifests.py:20-50). A second labels entry in deploy/k8s/base/kustomization.yaml with fields: [{kind: NetworkPolicy, path: spec/podSelector/matchLabels, create: true}] is an allowed key. kustomize then renders a policy that selects no pod, so the pod loses all isolation, and every check passes (reproduced by both reviews). Fix: the policy podSelector.matchLabels must be a non-empty subset of the Deployment's pod template labels; check the kustomization labels value exactly.
  2. The /32 check reads only prefixlen (tests/rendered_manifests.py:43). An IPv6 2001:db8::/32 with a matching Feeder URL passes; that block holds 2^96 addresses (reproduced). Fix: ip_network(cidr).num_addresses == 1.
  3. SECURITY.md:133-148, "What the Kubernetes pod does not separate", understates what the api can do. The api holds the store key and write access to the volume. It can remove the deletion_slice marker row (sync.py:310) or rewrite the Mirror and its event log, so the tombstones-missing stop does not protect against the api. State also:
    • the example overlay has no Tombstone export (overlay README.md:73), so any Rebuild there re-imports Forgotten messages;
    • in compose, the api also mounts data read-write, and compose has no egress control, so "egress reaches only the Feeder" holds for the pod only;
    • the containers share /dev/shm and the IPC namespace, both writable by uid 10001.
      The section is hard-wrapped; the rest of the file holds one paragraph per line.
  4. README.md:453 claims more than the step checks. It says the step "checks the rendered NetworkPolicy, pod and images", but the checker does not check the podSelector, the securityContext values or the image repository. It also uses the process word "architect rider" in a public README. Say "The pipeline's manifests step renders…" and list what it checks.

The rendered checker (tests/rendered_manifests.py)

It is the only gate for an overlay other than example. Each render below passes it (reproduced):

  1. Images: a name with no / but a dot (evil.example@sha256:…, messagesmind.v2@sha256:…) counts as qualified, and Docker resolves it to docker.io/library/…; any other registry (ghcr.io/evil/x@sha256:…) passes. Fix: the repository equals git.groupthink.asia/dev/messages-mind-mcp.
  2. Container securityContext values are not checked: allowPrivilegeEscalation: true, readOnlyRootFilesystem: false and capabilities.add pass. Pod runAsUser: 0 and automountServiceAccountToken: true pass.
  3. The api can reach the Secret through a projected volume, env.valueFrom.secretKeyRef or an nfs volume. Init-container mounts are not checked, so the api init container can copy feeder-token from sync-secrets-in, and the Secret items can gain feeder-token.
  4. The render has no allow-list of kinds: an extra Pod or DaemonSet with hostNetwork: true that mounts the Secret passes, and so does a LoadBalancer Service.
  5. Many checker lines have no synthetic proof; deleting each one leaves all tests green: in pod_violations hostPath, the securityContext keys, hostPort, sync ports, the probe port and init /tmp; in image_violations the dot check, the digest regex and the init containers; every branch of policy_violations; the kind count and ConfigMap parsing in rendered_violations; the FROM pin in containerfile_violations; the Feeder hostname, the port agreement, the token parent and the token names in compose_violations. Add a mutation row for each.

Other drift tests

  1. Containerfile (tests/test_deploy.py:136-205): a # escape=`` directive plus LABEL note=x\ hides a real RUN; SHELL [...] bypasses the RUN allow-list; USER 10001:10001 moved into the build stage passes, and the final image then runs as root (compose forbids user:, so compose runs it as root; this gap is older than #63); ENV LD_PRELOAD=… and a second ENV UV_LOCKED=0 pass. Fix: refuse a parser directive, refuse SHELL, require USER after the last FROM, and pin the ENV set.
  2. Compose (tests/test_deploy.py:211): extra_hosts: ["feeder:203.0.113.9"] sends the sync worker's Feeder token to that address, and passes. uts: host, cgroup: host, sysctls, group_add, runtime and cgroup_parent also pass. Fix: an exact key allow-list for each service.
  3. .dockerignore (tests/test_deploy.py:768-800): an added !**/*.key or !src/messages_mind_mcp/**/*token* passes, because the test checks named paths, not the exact pattern list. Pin the pattern list. The translator context_included (:249) has no unit test of a zero-directory **/, * against /, or parent matching; four changes to it go undetected.

The manifests CI step and its guard test (operator surface)

.woodpecker/validation.yaml is a may-not-mutate surface, so items 13 and 14 need an architect-rider commit or a separate operator PR (dev/stables ADR-0021).

  1. The guard test test_the_pipeline_renders_and_validates_every_kustomization (tests/test_deploy.py:901-922) passes each of these edits (reproduced): failure: ignore or when: {event: tag} on the step; kustomize build … > /dev/null; example.yaml dropped from kubeconform or from the checker; || true on kubeconform or the checker; -ignore-missing-schemas, -skip NetworkPolicy or -schema-location default; a second unverified download that overwrites the verified archive, or a different binary extracted; an HTTPS_PROXY entry; a legacy secrets: key. Fix: pin the step's command list exactly, and refuse failure, when, secrets and proxy keys on it.
  2. pip install uv==0.12.17 has no hash, and uv run builds the project with hatchling, which the lock does not hash. Both already hold for the check step.

Notes

  • The .dockerignore matcher agreed with a port of moby/patternmatcher on 6798 paths. Docker also admits a file inside a directory named *.py, for example src/messages_mind_mcp/x.py/stray.db.
  • rendered_manifests.main catches only OSError and YAMLError. A render with missing keys exits with a traceback, so it still fails closed.

Blocked by

  • none

Filed under: operator word "I grant authority to merge T4 through 21:00 aedt" sha256:cec4dd4fecbd

The correctness review and the security review of PR #63 (head `f929a91`) found no blocker. The rendered pod deploys safely: each process has its own memory-backed `/tmp` and its own secret volume, every image is the zero-digest placeholder, and the NetworkPolicy allows only the api port in and the Feeder `/32` out. The findings below are in the new checks and the documents. PR #63 cannot take a rework round, because the runner refuses a branch that carries a CI-surface diff, so they land here. ## Should fix first 1. **The rendered checker never compares the NetworkPolicy `podSelector` with the pod labels** (`tests/rendered_manifests.py:20-50`). A second `labels` entry in `deploy/k8s/base/kustomization.yaml` with `fields: [{kind: NetworkPolicy, path: spec/podSelector/matchLabels, create: true}]` is an allowed key. kustomize then renders a policy that selects no pod, so the pod loses all isolation, and every check passes (reproduced by both reviews). Fix: the policy `podSelector.matchLabels` must be a non-empty subset of the Deployment's pod template labels; check the kustomization `labels` value exactly. 2. **The `/32` check reads only `prefixlen`** (`tests/rendered_manifests.py:43`). An IPv6 `2001:db8::/32` with a matching Feeder URL passes; that block holds 2^96 addresses (reproduced). Fix: `ip_network(cidr).num_addresses == 1`. 3. **`SECURITY.md:133-148`, "What the Kubernetes pod does not separate", understates what the api can do.** The api holds the store key and write access to the volume. It can remove the `deletion_slice` marker row (`sync.py:310`) or rewrite the Mirror and its event log, so the `tombstones-missing` stop does not protect against the api. State also: - the example overlay has no Tombstone export (overlay `README.md:73`), so any Rebuild there re-imports Forgotten messages; - in compose, the api also mounts `data` read-write, and compose has no egress control, so "egress reaches only the Feeder" holds for the pod only; - the containers share `/dev/shm` and the IPC namespace, both writable by uid 10001. The section is hard-wrapped; the rest of the file holds one paragraph per line. 4. **`README.md:453` claims more than the step checks.** It says the step "checks the rendered NetworkPolicy, pod and images", but the checker does not check the `podSelector`, the `securityContext` values or the image repository. It also uses the process word "architect rider" in a public README. Say "The pipeline's `manifests` step renders…" and list what it checks. ## The rendered checker (`tests/rendered_manifests.py`) It is the only gate for an overlay other than `example`. Each render below passes it (reproduced): 5. Images: a name with no `/` but a dot (`evil.example@sha256:…`, `messagesmind.v2@sha256:…`) counts as qualified, and Docker resolves it to `docker.io/library/…`; any other registry (`ghcr.io/evil/x@sha256:…`) passes. Fix: the repository equals `git.groupthink.asia/dev/messages-mind-mcp`. 6. Container `securityContext` values are not checked: `allowPrivilegeEscalation: true`, `readOnlyRootFilesystem: false` and `capabilities.add` pass. Pod `runAsUser: 0` and `automountServiceAccountToken: true` pass. 7. The api can reach the Secret through a `projected` volume, `env.valueFrom.secretKeyRef` or an `nfs` volume. Init-container mounts are not checked, so the api init container can copy `feeder-token` from `sync-secrets-in`, and the Secret `items` can gain `feeder-token`. 8. The render has no allow-list of kinds: an extra `Pod` or `DaemonSet` with `hostNetwork: true` that mounts the Secret passes, and so does a `LoadBalancer` Service. 9. Many checker lines have no synthetic proof; deleting each one leaves all tests green: in `pod_violations` hostPath, the securityContext keys, hostPort, sync ports, the probe port and init `/tmp`; in `image_violations` the dot check, the digest regex and the init containers; every branch of `policy_violations`; the kind count and ConfigMap parsing in `rendered_violations`; the FROM pin in `containerfile_violations`; the Feeder hostname, the port agreement, the token parent and the token names in `compose_violations`. Add a mutation row for each. ## Other drift tests 10. **Containerfile** (`tests/test_deploy.py:136-205`): a `# escape=`` ` directive plus `LABEL note=x\` hides a real `RUN`; `SHELL [...]` bypasses the RUN allow-list; `USER 10001:10001` moved into the build stage passes, and the final image then runs as root (compose forbids `user:`, so compose runs it as root; this gap is older than #63); `ENV LD_PRELOAD=…` and a second `ENV UV_LOCKED=0` pass. Fix: refuse a parser directive, refuse `SHELL`, require `USER` after the last `FROM`, and pin the `ENV` set. 11. **Compose** (`tests/test_deploy.py:211`): `extra_hosts: ["feeder:203.0.113.9"]` sends the sync worker's Feeder token to that address, and passes. `uts: host`, `cgroup: host`, `sysctls`, `group_add`, `runtime` and `cgroup_parent` also pass. Fix: an exact key allow-list for each service. 12. **`.dockerignore`** (`tests/test_deploy.py:768-800`): an added `!**/*.key` or `!src/messages_mind_mcp/**/*token*` passes, because the test checks named paths, not the exact pattern list. Pin the pattern list. The translator `context_included` (`:249`) has no unit test of a zero-directory `**/`, `*` against `/`, or parent matching; four changes to it go undetected. ## The `manifests` CI step and its guard test (operator surface) `.woodpecker/validation.yaml` is a may-not-mutate surface, so items 13 and 14 need an `architect-rider` commit or a separate operator PR (dev/stables ADR-0021). 13. The guard test `test_the_pipeline_renders_and_validates_every_kustomization` (`tests/test_deploy.py:901-922`) passes each of these edits (reproduced): `failure: ignore` or `when: {event: tag}` on the step; `kustomize build … > /dev/null`; `example.yaml` dropped from kubeconform or from the checker; `|| true` on kubeconform or the checker; `-ignore-missing-schemas`, `-skip NetworkPolicy` or `-schema-location default`; a second unverified download that overwrites the verified archive, or a different binary extracted; an `HTTPS_PROXY` entry; a legacy `secrets:` key. Fix: pin the step's command list exactly, and refuse `failure`, `when`, `secrets` and proxy keys on it. 14. `pip install uv==0.12.17` has no hash, and `uv run` builds the project with `hatchling`, which the lock does not hash. Both already hold for the `check` step. ## Notes - The `.dockerignore` matcher agreed with a port of moby/patternmatcher on 6798 paths. Docker also admits a file inside a directory named `*.py`, for example `src/messages_mind_mcp/x.py/stray.db`. - `rendered_manifests.main` catches only `OSError` and `YAMLError`. A render with missing keys exits with a traceback, so it still fails closed. ## Blocked by - none --- Filed under: operator word "I grant authority to merge T4 through 21:00 aedt" sha256:cec4dd4fecbd
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dev/messages-mind-mcp#64
No description provided.