Repository navigation
Description
Proven end-to-end in a kind cluster against deploy/mecak8s as shipped, at
--posture=auto, headless, on the distroless image with no shell.
Impact
The Read tool serves /var/run/secrets/kubernetes.io/serviceaccount/token. The
token is live:
username: system:serviceaccount:mecatl:mecak8s-agent
rules: get/create/update/delete on coordination.k8s.io/leases (namespace mecatl)
Those Leases are mecak8s's single-writer guarantee (ADR 0048). An agent that
obtains this token can delete or hijack session leases — session denial of
service, and plausibly split-brain writes where two replicas write one session.
No shell is involved. The image is cgr.dev/chainguard/static (shell-less),
readOnlyRootFilesystem: true, runAsNonRoot, drop: ALL. None of that is
relevant, because the attack is an ordinary file read through a tool the agent
is supposed to have.
Root cause
--workspace defaults to the process working directory. The chainguard base
sets no WorkingDir, so cwd is /, and deploy/mecak8s/agent-deployment.yaml
never passes --workspace. The session workspace root is therefore the entire
container filesystem: the SA token is inside the workspace, so neither the
out-of-workspace escape guardrail nor any containment check fires. There is
nothing to escape.
Reproduction
A controlled OpenAI-compatible endpoint stood in for the model, so the result is
deterministic and offline. That choice bounds the claim: this proves the HARNESS
executes the read and returns the bytes to the model. It does not prove an LLM
can be induced to ask via injected content — a separate test needing a live
model.
- Deploy
deploy/mecak8swith--default-provider=opencodeand
--opencode-base-urlpointing at the stand-in (it must serve on :443; the
agent NetworkPolicy permits egress only on DNS, redis:6379, and 443). - Create a session with
workspace: "/"(the server default is cwd =/). - Have the model emit
Read{path: "var/run/secrets/kubernetes.io/serviceaccount/token"}. - The tool result carries the token; it is echoed into the model's final
message and out through the API response.
Verified against the API server with SelfSubjectReview and
SelfSubjectRulesReview.
What correctly held
Worth recording so a fix does not over-rotate — three controls worked:
- The pseudo-filesystem guard.
Read{path: "proc/self/environ"}was refused
with "path lies under a pseudo-filesystem (/proc, /sys, /dev): an in-process
FS read would expose the server's raw environment — never relaxed at any
posture" (internal/app/escapeclassifier.go). It correctly canonicalised the
RELATIVE path against the workspace root before judging. The provider API key
in the process environment was not reachable this way. - RBAC. Namespace-scoped, no
list, no secrets access.list leaseswas
refused. The blast radius is bounded by this and nothing else. - NetworkPolicy. Egress restricted to DNS, redis, and 443. A first attempt to
reach a stand-in provider on :9000 was silently dropped.
The gap is specifically that file-based credentials inside the workspace root are
served, while environment-based ones are protected.
Suggested fixes
- Set
--workspaceto a real project directory in
deploy/mecak8s/agent-deployment.yaml. One line; closes this. - Consider warning — or refusing — when a session workspace resolves to
/.
A workspace of "the entire filesystem" is almost always misconfiguration
rather than intent, and this is not mecak8s-specific: any containerised
deployment that omits--workspaceinherits cwd. - Consider a projected service-account token with a narrow audience and short
expiry.automountServiceAccountToken: trueis required for leases, so the
token cannot simply be removed.
Related
The environment-versus-disk asymmetry is directly relevant to the agent-identity
work: material held in process memory is behind a working guard, while material
loaded from a mounted file is not.
Activity
jhrozek commentedon Aug 26, 2026
Fixed in merged commit 1bf8998 (PR #763, Listener-scoped workspace authority). mecak8s now defaults
--workspaceto empty and uses the file-less authority, so the container root is no longer an implicit agent workspace. Configured workspaces are operator-assigned clean absolute roots; client-selected roots, filesystem profiles in file-less mode, and persisted off-root sessions fail closed. Coverage is incmd/mecak8s/main_test.goandinternal/adapter/server/workspace_authority_scenario_test.go. The Helm chart defaultsworkspace: ""and passes--workspaceonly when explicitly configured.