Skip to content

feat: add a central bootstrap so consumers carry only a pin - #3

Merged
tnunamak merged 1 commit into
mainfrom
feat/central-bootstrap
Aug 19, 2026
Merged

feat: add a central bootstrap so consumers carry only a pin#3
tnunamak merged 1 commit into
mainfrom
feat/central-bootstrap

Conversation

@tnunamak

Copy link
Copy Markdown
Member

Consuming repositories each duplicated ~90 lines of fetch-validate-delegate logic. That duplication is where both recent bugs lived — the worktree GIT_DIR failure and the GIT_CONFIG_GLOBAL origin-spoof hole — and fixing them took six near-identical patches across six repos. It was the third time this logic had drifted between copies: the central hook, the central installer, and vana-sdk's bootstrap had each ended up with a different scrub list, and the narrowest one was exploitable.

What this changes

scripts/bootstrap.sh holds that logic here, taking the pinned SHA via VANA_POLICY_SHA. Consumers keep a thin stub that does exactly two things: name the reviewed commit, and get this checkout onto disk.

Fetching by SHA is self-authenticating — git verifies the delivered objects hash to the requested commit, so a tampered response cannot satisfy it — and this script then re-validates origin, SHA and working-tree cleanliness before anything executes.

A fix here now reaches every repository when it advances its pin, with no per-repo edit.

What deliberately does not change

The pin stays per-repo. It is the supply-chain review gate: without it this repository could execute new code on every developer's machine at push time, which is precisely the property pre-commit refuses to give up (rev: must be an immutable ref; branch names are explicitly unsupported). The goal was never to remove the pin — it is one line — but to stop shipping ninety lines of logic alongside it.

Tests

The suite covers the new entry point: malformed and empty VANA_POLICY_SHA, unknown actions, and a policy cache whose origin is spoofed through GIT_CONFIG_GLOBAL. Existing coverage (worktree GIT_DIR, environment origin spoof, checksum gate, and all prior installer/scanner cases) is unchanged and still passes.

Assisted-by: AI

Consuming repositories duplicated ~90 lines of fetch-validate-delegate logic.
That is where the worktree GIT_DIR bug and the GIT_CONFIG_GLOBAL origin-spoof
hole both lived, and fixing them required six near-identical patches — the
third time this logic had drifted between copies.

scripts/bootstrap.sh holds that logic centrally, taking the pinned SHA through
VANA_POLICY_SHA. Consumers keep a thin stub that names the reviewed commit and
fetches it; fetching by SHA is self-authenticating, and this script re-validates
origin, SHA and cleanliness before anything executes. A future fix here reaches
every repository when it advances its pin, with no per-repo edit.

The pin stays per-repo deliberately: it is the supply-chain review gate that
keeps this repository from executing new code on developer machines without a
reviewed bump.

Tests cover the new entry point: malformed and empty SHAs, unknown actions, and
a cache whose origin is spoofed through GIT_CONFIG_GLOBAL.

Assisted-by: AI
@tnunamak
tnunamak merged commit 7f59130 into main Aug 19, 2026
1 check passed
@tnunamak
tnunamak deleted the feat/central-bootstrap branch August 19, 2026 01:17
tnunamak added a commit to vana-com/vana-smart-contracts that referenced this pull request Aug 19, 2026
* ci(hooks): replace the duplicated bootstrap with a thin stub

The ~90 lines of fetch-validate-delegate logic move to vana-com/.github as
scripts/bootstrap.sh (vana-com/.github#3). That duplication is where the
worktree GIT_DIR bug and the GIT_CONFIG_GLOBAL origin-spoof hole both lived,
and fixing them took six near-identical patches.

What stays here is a stub that names the reviewed policy commit and fetches it.
Fetching by SHA is self-authenticating, and the central bootstrap re-validates
origin, SHA and cleanliness before anything executes. A future policy fix now
reaches this repo when it advances its pin, with no edit to this file.

The pin stays local deliberately — it is the supply-chain review gate.

Assisted-by: AI

* fix(hooks): authenticate an existing policy cache before exec

Review caught a real regression in the first version of this stub: it exec'd
scripts/bootstrap.sh out of any pre-existing cache without checking it first,
so a poisoned cache ran arbitrary code BEFORE the central validation it
delegates to. Confirmed by planting a cache whose bootstrap printed and exited
0 — it executed.

Validates symlink, origin, pinned SHA and cleanliness ahead of the exec, and
refuses a symlinked bootstrap. These checks are deliberately duplicated with
the central bootstrap: that one still re-runs them for callers arriving another
way, but they must also happen here, before control transfers into the cache.

Verified: the poisoned cache is now refused at the origin check and never
executes, while fresh fetch, cached re-run and detection all still work.

Assisted-by: AI

* fix(hooks): neutralize execution-capable config on an unauthenticated cache

Review caught that a poisoned cache can execute code through its own
.git/config while being authenticated: core.fsmonitor runs a command during
`git status`, so the cleanliness check was itself an execution vector.
Environment scrubbing cannot reach this — the settings live in the cache's
repo-local config, which only -c overrides neutralize.

Pin moves to the policy carrying the same fix in bootstrap.sh, install-pre-push.sh
and hooks/pre-push.

Verified end to end: fresh install works, a planted core.fsmonitor never fires,
a modified cache bootstrap is refused, and detection still exits 1.

Assisted-by: AI

---------

Co-authored-by: tnunamak <everyone@appears.blue>
tnunamak added a commit to vana-com/vana that referenced this pull request Aug 19, 2026
Replaces this repository's copy of the EVM key-scan bootstrap with a
thin stub, following vana-com/.github#3.

## Why

Every consuming repository carried ~90 near-identical lines of
fetch-validate-delegate logic. That duplication is where both recent
bugs lived — the worktree `GIT_DIR` failure and the `GIT_CONFIG_GLOBAL`
origin-spoof hole — and fixing them required six near-identical patches
across six repos. It was the third time this logic had drifted between
copies, and the narrowest copy was the exploitable one.

## What changes

The validation, locking and delegation logic now lives in
`vana-com/.github` as `scripts/bootstrap.sh`. What stays here is a stub
that does two things: name the reviewed policy commit, and fetch it.

Fetching by SHA is self-authenticating — git verifies the delivered
objects hash to the requested commit — and the central bootstrap
re-validates origin, SHA and working-tree cleanliness before anything
executes.

**A future fix in the policy reaches this repository when it advances
its pin, with no edit to this file.**

## What deliberately does not change

The pinned SHA stays here. It is the supply-chain review gate: without
it the central repository could execute new code on every developer's
machine at push time. The aim was never to remove the pin — it is one
line — but to stop shipping ninety lines of logic alongside it.

Pin moves to `7f59130` (vana-com/.github#3).

## Verification

Against the real published policy:

- `install` in a clean repo fetches the policy, execs the central
bootstrap, and installs the hook
- a range containing a key in a secret-shaped declaration is detected
and exits 1
- a clean range exits 0
- from a **linked worktree** with an absolute `GIT_DIR`, the policy
cache is fetched and prepared correctly
- a cache whose origin is `attacker/evil.git` while `GIT_CONFIG_GLOBAL`
claims `vana-com/.github` is refused

Assisted-by: AI

---------

Co-authored-by: tnunamak <everyone@appears.blue>
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.

1 participant