| 1 | --- |
| 2 | type: bug |
| 3 | id: bd-75c8721 |
| 4 | status: closed |
| 5 | title: A push could write any namespace the hook did not name, replacement refs included |
| 6 | created: 2026-10-04 |
| 7 | source: adversarial review of the push boundary, 2026-10-04 |
| 8 | --- |
| 9 | |
| 10 | # A push could write any namespace the hook did not name |
| 11 | |
| 12 | The pre-receive hook guarded two things: protected refs, and the create-only attestation namespace. |
| 13 | Every other ref was open to any key that could push. Two of those open namespaces were holes. |
| 14 | |
| 15 | The first was `refs/replace/*`. A replacement ref makes git read one object in place of another, |
| 16 | wherever git looks the first one up. git honours replacement refs by default. The identity compiler |
| 17 | read the registry from the instance repository's tip with plain `git ls-tree` and `git show`, and |
| 18 | the integrator read the floor, the project's policy and a change's tree the same way. So a pushed |
| 19 | `refs/replace/<blob>` could swap in a registry that authorized any key as anything, or a floor that |
| 20 | required nothing, without moving a ref anyone watches. Every reader would have agreed on the forged |
| 21 | content, because every reader asks git the same question. |
| 22 | |
| 23 | The second was the integration-request namespace. [[dcr-e544f20]] |
| 24 | ([decisions/dcr-e544f20-access-is-verbs-on-projects.md](../decisions/dcr-e544f20-access-is-verbs-on-projects.md)) |
| 25 | defines a request verb whose gate is a check of namespace writes against the principals holding it. |
| 26 | No such check existed, so any key that could push could ask for anything to land. Who may file |
| 27 | requests is the human gate on a valley whose floor demands approval statements, so the verb had to |
| 28 | ship with its gate. |
| 29 | |
| 30 | ## The resolution |
| 31 | |
| 32 | The hook's rules are one Go program, [valleyhook/](../../valleyhook/), and the hook a host installs |
| 33 | only hands it the pushing principal, the project's declared protection, and the grants. It holds |
| 34 | every push to an allowlist. Protected refs take a push only from a declared writer. Attestation refs |
| 35 | are create-only. Integration requests take a write only from a principal holding the request grant. |
| 36 | Topic branches are open. Every other namespace is refused, and replacement refs are refused to every |
| 37 | push, declared writers included. A project opens any other namespace — release tags are the expected |
| 38 | case — with an `allow` entry in its protection block, naming the principals it opens to. |
| 39 | |
| 40 | The request grant is a boundary kind in the identity schema, `"request"`. The compiler writes each |
| 41 | holder into a grants file the hook reads. A host can also grant it by hand, which matters the first |
| 42 | time: the hook refuses the request that would land the registry change granting request, unless the |
| 43 | host already grants it to whoever files that change. |
| 44 | |
| 45 | Replacement refs are also turned off wherever git is read for a decision: in the identity compiler, |
| 46 | in the integrator and every program it runs, and in the `valley` CLI. Each one also drops the |
| 47 | inherited `GIT_*` variables that could point git at other objects. A replacement ref already on a |
| 48 | host is therefore inert, and valley-init reports any it finds on every activation without deleting |
| 49 | it. |
| 50 | |
| 51 | ## What remains |
| 52 | |
| 53 | A project without a protection block gets no hook, so its refs stay open to any push, replacement |
| 54 | refs included. The readers that make decisions no longer honour them there either. That openness is |
| 55 | what declaring no protection means. |
| 56 | |
| 57 | The hook does not check that an attestation ref's key hash belongs to the principal pushing it. The |
| 58 | signer and the pusher are routinely different principals. A host's own key signs the claims |
| 59 | `attest run` makes on it, and the operator's key pushes them. |
| 60 | |
| 61 | The request namespace does not record who filed a request. Any holder of the grant can therefore |
| 62 | replace or withdraw any request, not only its own. The grant is the boundary: who holds request is |
| 63 | decided in the registry, and the registry is governed. |
| 64 | |
| 65 | ## Related |
| 66 | |
| 67 | - [[dcr-e544f20]] |
| 68 | ([decisions/dcr-e544f20-access-is-verbs-on-projects.md](../decisions/dcr-e544f20-access-is-verbs-on-projects.md)) |
| 69 | — the request verb, whose gate this ships. |
| 70 | - [[dcr-b87f6e8]] |
| 71 | ([decisions/dcr-b87f6e8-identity-is-a-governed-registry.md](../decisions/dcr-b87f6e8-identity-is-a-governed-registry.md)) |
| 72 | — the registry the grant compiles from, and the boundary rule it follows. |