44// found a P0 — the agent advertised "read-only / cannot modify files" but its
55// bash allowlist (`git log *`, `cat *`, `ls *`) was bypassable to arbitrary
66// file READ (exfil) and WRITE (shell redirects ride inside the matched
7- // command). The fix denies bash entirely for the reviewer; these tests pin that
8- // it stays denied and that the read-only intent holds.
7+ // command). The v0.8.0 fix denied bash entirely; #978 relaxed that to "ask"
8+ // (every command requires explicit user approval — nothing auto-runs) so the
9+ // reviewer can `gh pr view` a PR URL. These tests pin the security intent:
10+ // NO bash pattern auto-runs (nothing evaluates to "allow"), and destructive
11+ // DDL stays hard-denied.
912import { test , expect } from "bun:test"
1013import { tmpdir } from "../fixture/fixture"
1114import { Instance } from "../../src/project/instance"
@@ -16,38 +19,46 @@ function bashAction(agent: Agent.Info, command: string) {
1619 return PermissionNext . evaluate ( "bash" , command , agent . permission ) . action
1720}
1821
19- // The reviewer agent advertises read-only; these pin that bash stays denied and
20- // arbitrary read/write is refused. (Previously test.todo'd for a dual-DB migration
21- // race in Instance.provide — legacy src/storage/db.ts vs core Effect-SQL migration
22- // both creating `project` — now resolved by the fresh-install core-schema adoption
23- // fix in src/storage/db.ts; re-enabled and passing.)
24- test ( "reviewer agent: bash is denied (base)" , async ( ) => {
22+ // The reviewer agent advertises read-only; these pin that NO bash command is
23+ // auto-approved and arbitrary read/write cannot run silently. (Previously
24+ // test.todo'd for a dual-DB migration race in Instance.provide — legacy
25+ // src/storage/db.ts vs core Effect-SQL migration both creating `project` —
26+ // now resolved by the fresh-install core-schema adoption fix in
27+ // src/storage/db.ts; re-enabled and passing.)
28+ test ( "reviewer agent: bash requires approval (base) — never auto-allowed" , async ( ) => {
2529 await using tmp = await tmpdir ( )
2630 await Instance . provide ( {
2731 directory : tmp . path ,
2832 fn : async ( ) => {
2933 const reviewer = await Agent . get ( "reviewer" )
3034 expect ( reviewer ) . toBeDefined ( )
31- expect ( PermissionNext . evaluate ( "bash" , "*" , reviewer ! . permission ) . action ) . toBe ( "deny" )
35+ // #978: "ask" instead of "deny" so `gh pr view <url>` is possible with
36+ // explicit user approval. The P0 was auto-run via a bypassable allowlist;
37+ // "ask" never auto-runs.
38+ expect ( PermissionNext . evaluate ( "bash" , "*" , reviewer ! . permission ) . action ) . toBe ( "ask" )
3239 } ,
3340 } )
3441} )
3542
36- test ( "reviewer agent: redirect-write and arbitrary-read bash commands are denied " , async ( ) => {
43+ test ( "reviewer agent: redirect-write and arbitrary-read bash commands never auto-run " , async ( ) => {
3744 await using tmp = await tmpdir ( )
3845 await Instance . provide ( {
3946 directory : tmp . path ,
4047 fn : async ( ) => {
4148 const reviewer = ( await Agent . get ( "reviewer" ) ) !
4249 // Write via redirect riding inside a once-allowed `git log *` pattern.
43- expect ( bashAction ( reviewer , "git log -p HEAD > ~/.ssh/authorized_keys" ) ) . toBe ( "deny" )
44- expect ( bashAction ( reviewer , "git diff HEAD >> ~/.bashrc" ) ) . toBe ( "deny" )
45- expect ( bashAction ( reviewer , "ls > /etc/cron.d/pwn" ) ) . toBe ( "deny" )
46- // Arbitrary file read (credential exfil) that `cat *` used to allow.
47- expect ( bashAction ( reviewer , "cat ~/.altimate/altimate.json" ) ) . toBe ( "deny" )
48- expect ( bashAction ( reviewer , "cat .env" ) ) . toBe ( "deny" )
49- // Even the previously-allowed read-only git inspection is now denied.
50- expect ( bashAction ( reviewer , "git log --oneline" ) ) . toBe ( "deny" )
50+ // These surfaced the v0.8.0 P0 as silent auto-runs; they must never be "allow".
51+ expect ( bashAction ( reviewer , "git log -p HEAD > ~/.ssh/authorized_keys" ) ) . toBe ( "ask" )
52+ expect ( bashAction ( reviewer , "git diff HEAD >> ~/.bashrc" ) ) . toBe ( "ask" )
53+ expect ( bashAction ( reviewer , "ls > /etc/cron.d/pwn" ) ) . toBe ( "ask" )
54+ // Arbitrary file read (credential exfil) that `cat *` used to auto-allow.
55+ expect ( bashAction ( reviewer , "cat ~/.altimate/altimate.json" ) ) . toBe ( "ask" )
56+ expect ( bashAction ( reviewer , "cat .env" ) ) . toBe ( "ask" )
57+ // Read-only git inspection also prompts (no allowlist at all).
58+ expect ( bashAction ( reviewer , "git log --oneline" ) ) . toBe ( "ask" )
59+ // Destructive DDL stays hard-denied regardless of the ask default.
60+ expect ( bashAction ( reviewer , "DROP DATABASE prod" ) ) . toBe ( "deny" )
61+ expect ( bashAction ( reviewer , "truncate users" ) ) . toBe ( "deny" )
5162 } ,
5263 } )
5364} )
0 commit comments