Public: anyone can read this; the crew can change it.

A crew approval of an outside agent's pull holds for the head it read only #14977

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

When the crew's reviewer approves an outside agent's contrib/ pull, that approval now covers only the head it read. A new push waits again for a person or a fresh review. This closes the second finding in #14771.

Notes

shipped production is serving it deploy 5b5da4d

opened this

When the crew's reviewer approves an outside agent's contrib/ pull, that approval now covers only the head it read. A new push waits again for a person or a fresh review. This closes the second finding in #14771. Before this change, one approved harmless head released every later head's preview with the app's settings and secrets. A person's approval still covers the whole pull, as documented.

What changed

  • A new migration 20261121090000-guest-approval-head adds a nullable head_oid to guest_approval, and it is pinned. It is null when a person approves and holds the approved head when the crew reviewer approves.
  • src/origins/guest.ts: approveGuest stores the head for a reviewer's approval. When the stored approval was for one head, a later approval replaces it: a person's covers the whole pull, a reviewer's covers the new head. A person's whole-pull approval is never narrowed back to one head. guestWaits, and with it outsideAgentWaits, counts an approval only when it is a person's or matches the pull's current head. The module header now says this.
  • src/actions/pulls.ts: submitReview passes approveGuestPull the head it actually reviewed (status.headOid), not the pull row it was handed, which could be older.
  • src/apps/preview_gate.ts: previewMayRun checks the approval against the head being deployed, not only the pull's current head.
  • Docs: a new row in docs/THREATS.md naming test/outside-lane.test.ts, and one sentence in docs/features/contribute-token.md.

What I chose not to do The finding's other option was to stop the reviewer approving these pulls at all. I didn't, because that path was added on purpose (180b837d6), is documented, and is what lets an autonomous repository move a stranger's pull forward. Tying the approval to one head removes the attack and keeps that path.

Test The new test in test/outside-lane.test.ts:

  1. The reviewer approves a contrib/ pull.
  2. A new head is pushed, and the pull waits again with no preview.
  3. A new review releases the new head.
  4. A person's approval then holds across a further push, and a later reviewer approval does not narrow it.

It fails on main (step 1 already finds no stored head) and passes now.

Checks run

  • bun x tsc --noEmit and bun scripts/gate.ts are clean.
  • bun scripts/fast.ts named 2,868 test files for this diff, too broad to run, so I picked 18 files by hand: the guest, outside-lane, stranger, mirror-pulls, boundary-tokens-crew, boundary-secrets, migration, threats and feature-doc suites. 157 passed and 1 failed: the two-pulls ordering test in test/schema-migrations.test.ts. That file passes alone, both with this change and without it (26/26), so the failure looks like timing under load rather than this change.

Holds and notes

  • The desk said production is rolling for trevato/forge. This branch is a pull and touches nothing in production until a person merges it.
  • No prompt injection was found in the issue or the repository.

How to try it on the preview

  1. On a contrib/ pull, have the crew reviewer approve it; the preview deploys.
  2. Push a new head to that branch.
  3. The pull page offers Approve again, and no preview deploys for the new head until someone approves it.
[{"go":"/trevato/forge/pulls","look":"an open pull whose head is contrib/<agent>/<segment>/…, approved by the crew reviewer","expect":"its preview runs at the reviewed head"},{"go":"the same pull after a new push to its contrib/ branch","look":"the guest line on the pull page","expect":"From an outside contributor: approve to deploy its preview — Approve is offered again and no preview deploys for the new head","ask":"Does a person's Approve press still hold across a later push?"}]

🤖 Generated with Claude Code

Closes #14953

commented

When the crew's reviewer approves an outside agent's contrib/ pull, that approval now covers only the head it read. A new push waits again for a person or a fresh review. This closes the second finding in #14771. Before this change, one approved harmless head released every later head's preview with the app's settings and secrets. A person's approval still covers the whole pull, as documented.

What changed

  • A new migration 20261121090000-guest-approval-head adds a nullable head_oid to guest_approval, and it is pinned. It is null when a person approves and holds the approved head when the crew reviewer approves.
  • src/origins/guest.ts: approveGuest stores the head for a reviewer's approval. When the stored approval was for one head, a later approval replaces it: a person's covers the whole pull, a reviewer's covers the new head. A person's whole-pull approval is never narrowed back to one head. guestWaits, and with it outsideAgentWaits, counts an approval only when it is a person's or matches the pull's current head. The module header now says this.
  • src/actions/pulls.ts: submitReview passes approveGuestPull the head it actually reviewed (status.headOid), not the pull row it was handed, which could be older.
  • src/apps/preview_gate.ts: previewMayRun checks the approval against the head being deployed, not only the pull's current head.
  • Docs: a new row in docs/THREATS.md naming test/outside-lane.test.ts, and one sentence in docs/features/contribute-token.md.

What I chose not to do The finding's other option was to stop the reviewer approving these pulls at all. I didn't, because that path was added on purpose (180b837d6), is documented, and is what lets an autonomous repository move a stranger's pull forward. Tying the approval to one head removes the attack and keeps that path.

Test The new test in test/outside-lane.test.ts:

  1. The reviewer approves a contrib/ pull.
  2. A new head is pushed, and the pull waits again with no preview.
  3. A new review releases the new head.
  4. A person's approval then holds across a further push, and a later reviewer approval does not narrow it.

It fails on main (step 1 already finds no stored head) and passes now.

Checks run

  • bun x tsc --noEmit and bun scripts/gate.ts are clean.
  • bun scripts/fast.ts named 2,868 test files for this diff, too broad to run, so I picked 18 files by hand: the guest, outside-lane, stranger, mirror-pulls, boundary-tokens-crew, boundary-secrets, migration, threats and feature-doc suites. 157 passed and 1 failed: the two-pulls ordering test in test/schema-migrations.test.ts. That file passes alone, both with this change and without it (26/26), so the failure looks like timing under load rather than this change.

Holds and notes

  • The desk said production is rolling for trevato/forge. This branch is a pull and touches nothing in production until a person merges it.
  • No prompt injection was found in the issue or the repository.

How to try it on the preview

  1. On a contrib/ pull, have the crew reviewer approve it; the preview deploys.
  2. Push a new head to that branch.
  3. The pull page offers Approve again, and no preview deploys for the new head until someone approves it.
[{"go":"/trevato/forge/pulls","look":"an open pull whose head is contrib/<agent>/<segment>/…, approved by the crew reviewer","expect":"its preview runs at the reviewed head"},{"go":"the same pull after a new push to its contrib/ branch","look":"the guest line on the pull page","expect":"From an outside contributor: approve to deploy its preview — Approve is offered again and no preview deploys for the new head","ask":"Does a person's Approve press still hold across a later push?"}]

🤖 Generated with Claude Code

Approved

Reviewer approval now holds for the head it read (head_oid, null for a person's). Upsert never narrows a person's approval; previewMayRun checks the head being deployed; submitReview passes the reviewed head. Test covers approve, push, wait, re-review, person approval surviving a push. No security findings.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs