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, read one object at a time within fixed bounds on depth, entries,
and bytes, each checked before anything past it is read. Every note must open under the keys a
controller here accepts, the way a verifier opens it, be about that tree, and carry a verified
signature under that key hash. A host that names no such keys accepts no attestation.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.
The note envelope has one reading, the note module (note/), which attest signs and
verifies with and the hook checks pushed notes with. A relayer can change a note's signature block
and nothing else, and every line it could add that one reader refuses, every reader refuses. So a
note the hook lets into the create-only namespace is a note every verifier opens.
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.
Things around the hook could still have bypassed it, and each is closed.
A pre-receive hook the module did not write, or a core.hooksPath set at any scope, to an empty
value included, would run instead of the policy. valley-init fails the activation over either, and a
project that wants a hook of its own composes it after the policy, where it can only refuse more.
A failed activation leaves no write path open. The git user's login shell is the valley's
(valleyhook shell), and it refuses every push until valley-init has recorded that it converged on
the configuration the shell was rendered with. valley-init removes that record before anything else
it does and writes it last. The operator can also hold pushes with a file valley-init never touches.
Fetches stay open.
The principal arrives one way. The shell reads the key sshd authenticated, finds that key's entry in
the files sshd authorized it from, and takes the tag on it. A principal or any GIT_* variable the
session arrived with is dropped, so a misconfigured sshd that passes client environment through
still names nobody and sets nothing git reads. The module also refuses such an sshd outright: an
AcceptEnv or SetEnv that could admit the principal or a GIT_* variable, in any Match block,
with the keyword in any case, and any PermitUserEnvironment but no. It refuses a key declared
under two tags, and the git user's keys come only from the declared and compiled files.
The instance repository must declare protection of the ref the floor and the registry are read from.
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.
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, and because requests already queued were filed before anything checked who filed them.
services.valley.grants.request for whoever files the registry change, and protect the
instance repository's main.core.hooksPath. Read the replacement
refs it reports before deleting them.A protected project that moves onto the valley afterwards gets its first main by a seed on the
host (integration.md, A protected stream starts from a seed).