Skip to content

fix(faucet): take each repository rename once and never keep a stale name - #83

Merged
ThomasK33 merged 9 commits into
mainfrom
fix/repo-name-binding
Nov 23, 2026
Merged

ThomasK33 merged 9 commits into
mainfrom
fix/repo-name-binding

Conversation

@ThomasK33

@ThomasK33 ThomasK33 commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Why

Goal: a service's repo: grant (and an org: grant, through the repository's owner ID) must never authorize a repository through a stale name binding. This fixes two Vercel Security Review findings, which share the binding code:

  • faucet/3, "Missed repository renames preserve former-owner service access after transfers": a rename whose store write failed was still acknowledged, and a later transfer from the new name could not repair the old one.
  • faucet/4, "Replayed transfers restore obsolete service grants when a repository returns to a prior name": a kept, signed transfer body could be sent again under a new delivery GUID and bring back the old binding.

What changed

  • A repository renamed/transferred delivery whose write fails answers 500. Service.RedeliveryWants (wired in cmd/faucet) makes redelivery ask for a failed one again; other deliveries keep their answers.
  • Store.RenameRepository takes a RepositoryRename and records the SHA-256 of the signed body in the same transaction as the names (migration 000019_repo_renames). A body that the store judged before changes nothing, whatever its GUID.
  • A fresh rename from a name that faucet does not hold quarantines the repository (faucet_repos.quarantined_at) and logs a warning: it answers to no name, so neither a stale name nor a former name from a kept old body reads it. Only a fresh rename from the held name lifts it, or an operator writing its current name to the row; a quarantine keeps no name, because kept bodies can chain. A rename that faucet's redelivery asked for changes nothing then. (Earlier heads took the delivered names, then kept them as a candidate; Vercel's review and the verifier showed that each let kept bodies rebind a former name.)
  • Docs: security.md gains "Repository names" with the limits below; service-accounts.md, redelivery.md, upgrading.md and the verify-faucet feature page follow.

Scope

Repository names only. An owner's login moves with any delivery, and a manual GitHub redelivery can move it back: that limit is unchanged and already in service-accounts.md.

Tradeoffs

GitHub signs only the body, and the body holds no time that orders deliveries. So a signed rename body that faucet never took (one that never reached it, one from before this migration, or a manual GitHub redelivery of one it answered 500 to) still binds its names until the next rename when it moves the repository from the name faucet holds (from any other name it only quarantines, which denies and grants nothing), and two renames that arrive out of order leave the older name. security.md says so. Digests are kept for good: a body stays signed.

Blast Radius

Only hosts that record repositories (FAUCET_PUBLIC_URL). A rolling deploy: a build before 000019 can't start against it. Embedders: new RenameRepository signature and storetest subtests; pass RedeliveryWants instead of RawWants.

Verification

  • Failing-first commit fc50733: missed-rename-then-transfer, transfer-away/back/replay and failed-write tests fail on main and pass here; storetest contract runs on pgstore and the fake.
  • Happy path fed by GitHub's published repository transferred/renamed examples (octokit/webhooks payload-examples at bc5f6fd).
  • go test -race ./... with Postgres, -tags faucet_e2e, golangci-lint, sqlc/mod tidy clean, verify-docs checks, verify/ e2e suite.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: xhigh

A rename or transfer whose store write fails is acknowledged, a transfer
after a missed rename leaves the old name bound, and a replayed transfer
body gives a repository a name back (Vercel findings faucet/3, faucet/4).
The sample-transfer-and-rename test passes already; it pins the happy path
with GitHub's published payload examples.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
…name

A service's repo: grant resolves through the name that rename and
transfer deliveries give a repository (Vercel findings faucet/3, faucet/4).

- A rename or transfer whose store write fails answers 500, and
  redelivery now asks again for one (Service.RedeliveryWants).
- Store.RenameRepository records the SHA-256 of each rename body in the
  transaction that writes the names (migration 000019_repo_renames), so the
  same body under another delivery GUID changes nothing.
- A fresh rename from a name that faucet does not hold replaces the stale
  name and logs a warning. One that redelivery asked for still moves a
  name only from the name that faucet holds.

docs/security.md names what faucet still cannot tell apart: a signed
rename body that it never took, and renames that arrive out of order.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `xhigh`_
@ThomasK33

Copy link
Copy Markdown
Member Author

PASS+NOTES at 2c66e26

Independent check of faucet/3 and faucet/4 at this head against base 157e81b (main).

Gates at head: gofmt clean; build, vet and golangci-lint (0 issues) pass; go test -race -count=1 ./... passes on all packages. The first run hit DROP DATABASE cleanup timeouts in pgstore because my own tests loaded the same Postgres; a clean rerun passed. -tags faucet_e2e ./cmd/faucet passes. tidy and sqlc leave git status clean. Migration 000019 goes up, down and up again on a scratch DB, its CHECKs reject a 31-byte digest and repo_id 0, and the pinned version test expects 19. The changes.repository.name.from and changes.owner.from.user|organization fields match the octokit/webhooks repository/renamed and repository/transferred payload examples.

Attack tests ran through the real router (newLoginServer: pgstore, client_credentials token, MCP wait tool, a service granted only repo:<name>):

Case base head
A. A rename old/r→old/s is missed, then the transfer old/s→new/s arrives; probe repo:old/r bound, reads the new owner's events (leak) unbound; repo:new/s reads them
B. Transfer away, transfer back, then replay the first body under a new GUID bound (leak) unbound
B'. The same replay under the same GUID (a manual redelivery) bound (leak) unbound
C. The body re-serialized, sent with the original signature 401 401
F. The rename write fails (table renamed away) n/a rename 500; workflow_run 200; repository publicized 202
F2. The failed rename comes again as a faucet redelivery with nothing newer n/a applies
G. 40 concurrent rename posts of one repo, 10 distinct bodies all 202 all 202, 10 digest rows, no errors

Notes (each is disclosed in docs/security.md; none blocks):

  1. A body taken before the migration has no digest row. Replaying one under a new GUID now applies even when its from no longer matches the current name. Main refused that case (D: base unbound, head bound). It needs a kept signed body, which in practice means a hook admin. Suggestion: tell operators in docs/upgrading.md to rotate the webhook secret after deploying 000019. That invalidates every signed body from before the migration.
  2. A manual GitHub redelivery of a rename that faucet answered 500, sent after a newer transfer, binds the stale name (E: head bound). This happens only when faucet's redelivery has not yet tracked that GUID, and always on a host without redelivery. When redelivery tracks the GUID, the late path refuses it (head unbound). GitHub keeps deliveries for 3 days and only hook admins can redeliver. Base never answers 500 here, so this case is new, but its effect matches the stale binding that A shows on main.
  3. In docs/upgrading.md, the older raw-events section (line 116) still names Service.RawWants for redelivery.Deps.Wants. The new section supersedes it.
  4. The Vercel Security Review check also fails on main (open findings on the repo).

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
Vercel's review of this PR found that a kept signed rename, which faucet
never judged, rebinds a repository to a former name when its from does
not match. These tests pin the quarantine that replaces that path: such
a rename binds neither name until the next fresh rename from one of
them.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
A fresh rename or transfer whose from names neither name that faucet
holds may follow a missed rename or be a kept old body, and faucet cannot
tell which. It now keeps the rename's names as a candidate and resolves
no name for the repository, so neither the stale name nor a former name
from an old body reads it. The next fresh rename from the held name or
the candidate takes its names and lifts the quarantine; a late one never
does. Migration 000019 adds the candidate columns.

This closes the finding that Vercel's review raised against the earlier
head, where such a rename took the delivered names.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

FAIL at a350e83

Independent check of faucet/3, faucet/4 and the PR finding superblink-events/14 at this head, against base 157e81b (main) and the earlier head 2c66e26. Stopped early at the root's request once the bypass below was confirmed; the verify/ e2e suite did not run.

Gates at head: gofmt clean; build, vet and golangci-lint (0 issues) pass; go test -race -count=1 ./... and -tags faucet_e2e ./cmd/faucet pass; tidy and sqlc leave git status clean. Migration 000019 goes up, down and up on a DB at 000018 with a row in it, and its CHECKs refuse a half-set candidate, candidate_owner_id 0 and a 31-byte digest.

Attack tests through the real router (newLoginServer, pgstore, client_credentials token, MCP wait tool, a service holding one grant). "pre-migration" means the digest rows are deleted:

Case base 2c66e26 head
A. Rename old/r→old/s missed, then transfer to new/s; repo:old/r bound unbound unbound (quarantined)
B. Transfer away, back, replay the first body (new GUID, same GUID) bound – unbound
D. One kept pre-migration rename whose from the row lacks (finding 14) unbound bound unbound (quarantined)
CHAIN. Two kept pre-migration renames that chain (old/a→old/r, old/r→old/s), replayed after the repo moved to new/s; repo:old/s and org:old unbound bound bound, read the new owner's events
A+. The missed body of A sent fresh after the quarantine bound bound bound (same as base, documented)
Missed rename redelivered by faucet after the transfer – – changes nothing; its body is then used up, a fresh replay does nothing
Missed rename then transfer, then the new owner renames stale name bound heals heals (new/t bound, old names not)
Normal rename + transfer; owner renamed before the transfer ok ok ok
Quarantined row plus an older row that held the same name – older row bound unbound, no fallback
Rename write fails: 500, then a faucet redelivery with nothing newer 202 – 500, then applies
The CHAIN bodies racing a legit rename (8 runs) 0/8 bound 3/8 4/8 bound to old/s

Why CHAIN works: the first kept body fails the from check, so it quarantines the row and stores its own names as the candidate. The second kept body renames from that candidate, so it passes the check, applies its names and lifts the quarantine. A kept body therefore picks the candidate, and the next one rebinds a former name. Main refuses both bodies. This is the finding 14 attack with two bodies instead of one. It needs two consecutive renames whose bodies faucet took before 000019, which the optional secret rotation in docs/upgrading.md would kill.

Doc made wrong: docs/security.md#repository-names says a body from any other name "only stops the repository from answering to a name, which denies a grant and gives none". CHAIN shows it also gives the candidate that the next kept body lifts.

Notes:

  1. Quarantine is fail-closed for legit users. Until the next fresh rename, a quarantined repo answers to no name, under repo: and org: grants alike. The docs name no operator remedy.
  2. The 000019 down file also drops the candidate columns, which rebinds a quarantined row's stale name. docs/upgrading.md mentions only the table.
  3. Vercel Security Review fails at this head because finding superblink-events/14 is still open on the branch. Per CHAIN, it is still valid here.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

The verifier of a350e83 found that a kept body which quarantines a
repository sets the candidate that a second kept body, renamed from it,
then lifts. These tests pin a quarantine that only a fresh rename from
the name faucet holds can lift.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
A quarantine kept the names of the rename that caused it, and a rename
from them lifted it, so two kept bodies that chain gave a former name
back. A quarantine now keeps no name: faucet_repos.quarantined_at marks
the row, and only a fresh rename from the name that the row holds lifts
it. An operator lifts one by deleting the row.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33

Copy link
Copy Markdown
Member Author

PASS+NOTES at 0c1328c (independent verifier; base 157e81b)

Findings 3, 4 and pr83-14 are closed, and so is the chain that failed a350e83. No sequence of kept bodies that I tried binds a name that main would not also bind from the same bodies.

Gates at head

gofmt clean · go build ./cmd/faucet · go vet ./... · golangci-lint 0 issues · go test -race -count=1 ./... ok (CI=1, Postgres 18) · -tags faucet_e2e ./cmd/faucet ok · go mod tidy and sqlc generate leave git clean · migration 000019 up/down/up on a scratch DB (the down keeps the row's full_name, and the second up recreates the table and its checks) · base binary on a v19 DB refuses with no migration found for version 19, as upgrading.md says · Vercel Security Review: success at 0c1328c, "No open findings", and vercel security vulnerabilities list --status open on the branch returns [].

Attacks (real router, repo: and org: service grants, wait tool; pre-migration bodies simulated by deleting faucet_repo_renames)

Case base head
F3: missed rename, then transfer repo:old/r and org:old read the moved repo quarantined; old and new names refused
F4: away, back, replay first (new GUID and same GUID) repo:old/t reads seen before, new/t stays bound
pr83-14: one kept body, mismatched from no bind quarantined, no bind
Chain a350e83 (old/a→old/r, then old/r→old/s) no bind quarantined, no bind
Chains in orders 21, 12, 121, T12, T21, 1T2, 2T1 (T = the transfer replayed) no bind quarantined, nothing bound
Chain racing a legit rename (8 runs) new/t new/t (quarantined in 6 of 8, by order), never old/s
Quarantine, then ordinary delivery / late rename from the held name – stays quarantined (RecordRepository and Late never lift)
Late rename with mismatched from no change no change, no quarantine
Older row holding the same name as a quarantined row stale row resolves refused
Write fails → 500, then faucet redelivery 202, applied 500, then applied
Same fresh body ×4 at once – 1 digest row, applied once

I also drove the live faucet_e2e binary over HTTP with signed webhooks, OAuth client credentials and MCP wait_for_github_events. Base leaks for F3 and F4. Head refuses F3, F4 and the chain, and binds the normal rename-then-transfer.

Legitimate users: a rename then a transfer, a 4-step rename/transfer/rename/transfer-back chain, an owner renamed (and seen) before a transfer, and a case-different from all bind the current name, and org: follows. Wire values match octokit/webhooks repository/renamed and repository/transferred payload examples. The docs I checked (security.md#repository-names, service-accounts.md, upgrading.md 000019, verify-faucet features/service-accounts.md) match what I observed.

Notes (none block)

  1. The operator remedy reopens a window. After DELETE FROM faucet_repos WHERE repo_id = …, the next delivery inserts the name that it gives. That delivery can be a kept rename body with any from: a pre-migration body or one that never reached faucet. Later ordinary deliveries do not correct the name (RecordRepository is DO NOTHING). In my test, kept chain bodies sent after the delete bound old/s, and both repo:old/s and org:old read the repo. Base has the same insert-on-no-row behaviour, and security.md describes it literally, so I did not block. Still, someone who can force a quarantine with a kept body can re-poison the row while the operator is undoing it. Suggestion: tell operators to rotate the webhook secret before deleting the row, or make the remedy an UPDATE to the known-current name.
  2. Quarantine is sticky, as documented, and a legitimate user can hit it. One case: an owner is renamed, faucet gets no delivery from it, and then the repo is transferred (from = new login). Another: the new owner renames after a quarantine, and that does not lift it. In both cases base left the stale name bound.
  3. The refusal message is misleading. A quarantined repo answers "faucet has received no webhook delivery from X yet", which is misleading for operators. Only the server log says that the repo is quarantined.
  4. Base has the same problem (one line): a kept body under a fresh GUID moves the owner's login back. A kept transfer from that old login then matches "under the owner's current login".

Reproducers: vattack_internal_test.go and vattack2_internal_test.go, dropped into cmd/faucet (go test -run TestV -v ./cmd/faucet).


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

… row

The verifier of 0c1328c showed that deleting the row lets the next
delivery, which can be a kept body, give the repository any name.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model: `anthropic:claude-opus-5-5` • Thinking: `high`_
@ThomasK33
ThomasK33 merged commit 954b0e6 into main Nov 23, 2026
10 checks passed
@ThomasK33
ThomasK33 deleted the fix/repo-name-binding branch November 23, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants