Commit c37ca88
fix(security): two blockers found by adversarial review, not by the suite (BRO-2227)
Both were guards that existed, read correctly, and did not hold.
1. AN EMPTY READING OF THE CONTEXT WALKED EVERY ACCEPT GATE.
`proposeFromDirectory` skips dot entries, but the SOURCE_EMPTY check runs BEFORE
that filter. A directory holding only dot entries therefore produced a proposal
with no state, no actions and -- decisively -- no blocking questions. Every
downstream gate is keyed on there being something to ask about, so
BLOCKING_QUESTIONS_OPEN could not fire and neither could the reconciliation
check. Result: an ontology minted with ZERO human input, recording a named
person as having accepted a model of their own context.
This is not a contrived input. A freshly provisioned tenant workspace contains
only `.claude`, so the empty reading IS the first-run path. Reproduced end to
end before fixing: propose -> 0 fields, 0 actions, 0 questions; accept with no
answers -> ACCEPTED, acceptedBy "anyone".
Fixed at two layers: propose now fails DEGENERATE_CONTEXT when nothing readable
was found, and activate refuses NO_ACTIONS for an empty action space however the
proposal arrived -- a domain with no actions cannot have anything happen in it.
2. A SYMLINK DEFEATED THE ONLY PATH GUARD ON THE AGENT-FACING SURFACE.
confine() was purely lexical: resolve() then startsWith(). path.resolve never
follows symlinks, so `ln -s /somewhere ws/data` produced a target that starts
with the base and points anywhere. Reproduced: an outside directory's listing --
`customer_pii/`, `private.key` -- was read into a proposal, rendered into the
message sent to the human, and persisted in the pending record.
This one matters more than it would elsewhere: the surrounding tenant sandbox
confines writes but NOT reads, so a lexical-only guard was the difference
between describing the tenant's own workspace and describing whatever they
pointed a link at.
Now checked twice -- lexically, then physically via realpathSync. The base is
realpath'd too, because /tmp is itself a symlink on macOS and comparing a
resolved target against an unresolved base fails on ordinary paths, which would
push someone to loosen the check for the wrong reason. Adds PATH_NOT_FOUND and
WORKSPACE_UNREADABLE so a missing path and an unreadable workspace are not
reported as escapes.
test/regression.test.ts pins both. Every refusal is PAIRED WITH A CONTROL that
must pass -- a real subdirectory is still allowed, a workspace with visible
entries still proposes, a proposal with actions still activates -- because a
guard that refuses everything is indistinguishable from a working one on the
refusal case alone, which is exactly how both of these survived the tests
written beside them.
Mutation-proven, anchors confirmed unique before each mutation: disabling
DEGENERATE_CONTEXT kills 1, disabling NO_ACTIONS kills 1, reverting confine() to
lexical-only kills 3. Restored 188 pass, 0 fail.
Also: adding codes in src/core broke src/tools/errors.ts at the type level,
which the 175-test suite did not catch because `bun test` does not typecheck.
The union is hand-mirrored; deriving it was attempted and does not typecheck
cleanly against the re-export shape, so the drift hazard is documented in place
rather than left implicit.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 6e6b6ee commit c37ca88
21 files changed
Lines changed: 7492 additions & 318 deletions
Large diffs are not rendered by default.
| 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 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
0 commit comments