The pre-receive hook guarded two things: protected refs, and the create-only attestation namespace. Every other ref was open to any key that could push. Two of those open namespaces were holes.
The first was refs/replace/*. A replacement ref makes git read one object in place of another,
wherever git looks the first one up. git honours replacement refs by default. The identity compiler
read the registry from the instance repository's tip with plain git ls-tree and git show, and
the integrator read the floor, the project's policy and a change's tree the same way. So a pushed
refs/replace/<blob> could swap in a registry that authorized any key as anything, or a floor that
required nothing, without moving a ref anyone watches. Every reader would have agreed on the forged
content, because every reader asks git the same question.
The second was the integration-request namespace. [[dcr-e544f20]] (decisions/dcr-e544f20-access-is-verbs-on-projects.md) defines a request verb whose gate is a check of namespace writes against the principals holding it. No such check existed, so any key that could push could ask for anything to land. Who may file requests is the human gate on a valley whose floor demands approval statements, so the verb had to ship with its gate.
The hook's rules are one Go program, valleyhook/. It runs on every project a host serves, protected or not, and the hook a host installs only hands it the pushing principal, the project's declared push policy, the grants, and the keys attestations are checked against. A write must pass every rule that applies to its ref, and no rule stands in for another:
<tree digest>/<key hash>. It
must point at a tree of notes, every note about that tree and signed under that key hash. Where
the host names the keys a controller accepts, the signature must verify under one of them.The request grant is a boundary kind in the identity schema, "request". The compiler writes each
holder into a grants file the hook reads. A host can also grant it by hand, and the two add up. The
hand grant matters the first time: the hook refuses the request that would land the registry change
granting request, unless the host already grants it to whoever files that change.
Replacement refs are also turned off wherever git is read for a decision: in the identity compiler,
in attest (so a standalone attest verify too), in the integrator and every program it runs, and
in the valley CLI. Each one also drops the inherited GIT_* variables that could point git at
other objects. A replacement ref already on a host is therefore inert, and valley-init reports any
it finds on every activation without deleting it.
Three things around the hook could still have bypassed it, and each is refused. A pre-receive hook
the module did not write, or a core.hooksPath from any scope, would run instead of the policy, so
valley-init fails the activation over either; a project that wants a hook of its own composes it
after the policy, where it can only refuse more. The instance repository must declare protection of
the ref the floor and the registry are read from. And sshd is held to the one way a principal
arrives: the tag on the key's own entry. The module refuses an sshd that accepts the principal
variable from the client, sets it itself, or reads more of the user's environment than that one
variable. It also refuses a key declared under two tags. The git user's keys come only from the
declared and compiled files, and valley-init refuses a ~/.ssh/environment in its home.
The hook does not check that an attestation's signer is the principal pushing it. The signer and the
pusher are routinely different principals. A host's own key signs the claims attest run makes on
it, and the operator's key pushes them. On a host that names no verifier keys, the hook checks what
a note claims about its signer and not the signature, so a name there can still be taken by a note
claiming a signer it was not signed by.
The request namespace does not record who filed a request. Any holder of the grant can therefore replace or withdraw any request, not only its own. The grant is the boundary: who holds request is decided in the registry, and the registry is governed.
The order matters, because the hook refuses the very request that lands a registry change.
services.valley.grants.request for whoever files the registry change, and protect the
instance repository's main. Then deploy.core.hooksPath, a
~/.ssh/environment in the git user's home. Read the replacement refs it reports before deleting
them.