Skip to content

ci(hooks): replace the duplicated bootstrap with a thin stub - #72

Merged
tnunamak merged 3 commits into
mainfrom
refactor/thin-keyscan-stub
Aug 19, 2026
Merged

ci(hooks): replace the duplicated bootstrap with a thin stub#72
tnunamak merged 3 commits into
mainfrom
refactor/thin-keyscan-stub

Conversation

@tnunamak

Copy link
Copy Markdown
Member

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

tnunamak added 3 commits August 18, 2026 20:18
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
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
… 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
@tnunamak
tnunamak merged commit f37545c into main Aug 19, 2026
3 checks passed
@tnunamak
tnunamak deleted the refactor/thin-keyscan-stub branch August 19, 2026 01:37
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