Commit cf1a84b
committed
Self-audit: agent could overwrite its own guardrails; missing-env was retryable
Two bugs found by inspecting the built image before the review agents reported.
BLOCKER -- the agent owned its own constraints. The runner runs AS the `pi` user, and the
Dockerfile COPY --chown=pi:pi'd the guardrails, the runner, and (via chown -R /app) pi's own
node_modules. Verified against the real image: as pi, all three were writable.
echo x > /opt/pi-dispatch/HARD_RULES.md # succeeded
echo x > /app/image/runner/run-job.mjs # succeeded
echo x > /app/node_modules/.poison # succeeded
/job:ro exists precisely so the agent cannot rewrite its instructions; leaving its code and
its safety floor agent-writable is the identical hole through a different door. The container
is ephemeral so it is not trivially exploitable within one run, but that argument is too
fragile to rest a security property on -- if anything re-reads the guardrails mid-session
(compaction, which is OQ-003) the floor is poisonable, and the fix costs nothing.
Only ~/.pi/agent (pi writes auth.json) and /ms-playwright (pi reads browsers) are chowned to
pi now. The guardrails and /app are root-owned and `chmod -R a-w`; pi reads and executes them,
which is all it needs. Verified: all three now Permission denied to pi, pi still imports the
package, agent dir still writable.
Correctness -- a missing required env var exited 1 (retryable). requireEnv threw
"missing required env: PI_PROVIDER", which classifyThrow's config regex did not match, so it
fell to EXIT_INFRA. But the worker passes the same absent value on every retry, so the queue
would pay to rediscover a deterministic misconfiguration. Now matched -> exit 2. Verified in
the image: the runner exits 2. Added classify-throw.test.mjs covering the config/infra split.1 parent 3e2be9b commit cf1a84b
3 files changed
Lines changed: 55 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
97 | 97 | | |
98 | | - | |
99 | | - | |
100 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
101 | 103 | | |
102 | 104 | | |
103 | | - | |
104 | | - | |
| 105 | + | |
105 | 106 | | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
111 | 117 | | |
112 | 118 | | |
113 | | - | |
114 | | - | |
115 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
116 | 123 | | |
117 | 124 | | |
118 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
0 commit comments