ci(hooks): resolve the policy cache from a worktree and harden the origin check - #24
Merged
Merged
Conversation
added 2 commits
August 18, 2026 17:05
…igin check Applies the fix already merged in vana-com/.github#2 and vana-com/vana-sdk#189. Git exports an absolute GIT_DIR into hook processes from a linked worktree, so a bare `git -C "$policy_dir"` read the pushing repo's remote/HEAD/status and refused a valid policy cache. Routes every policy-targeting command through a `policy_git` helper that scrubs the inherited repository environment, derived from `git rev-parse --local-env-vars` plus the GIT_CONFIG_* file overrides — without GIT_CONFIG_GLOBAL the origin check is satisfiable from the caller's environment against an attacker-controlled cache. Bumps CENTRAL_POLICY_SHA to vana-com/.github@9990452 so the fix is end-to-end. Assisted-by: AI
The reusable workflow file is byte-identical between 5f1b4b1 and 9990452, so CI behavior is unchanged — but the workflow calls install-gitleaks.sh, which 9990452 fixes for macOS (Darwin ships its own /sbin/sha256sum that rejects the GNU long options, so the download checksum failed for every download). Keeps the CI pin and the bootstrap pin on the same reviewed policy commit. Assisted-by: AI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The EVM key-scan bootstrap cannot pass from a git worktree, and its policy-cache origin check is satisfiable from the caller's environment. Both are fixed in the central policy (vana-com/.github#2) and in vana-sdk (vana-com/vana-sdk#189, merged); this applies the same fix here.
Worktree bug
Git exports
GIT_DIRinto hook processes. In a linked worktree that value is an absolute path, sogit -C "$policy_dir" ...still resolves against the pushing repository and reports ITS remote, HEAD and status instead of the policy cache's. Validation then rejects a perfectly good cache:In a normal checkout
GIT_DIRis the relative.git, which happens to resolve correctly under-C— which is why this only bites worktrees. A hook that cannot pass is a hook developers route around with--no-verify, which is the outcome this policy exists to prevent.Origin check hardening
The scrub list is derived from
git rev-parse --local-env-varsrather than hardcoded. Beyond the directory variables that fix the worktree bug, that covers the repository-local variables (GIT_SHALLOW_FILE,GIT_GRAFT_FILE,GIT_REPLACE_REF_BASE,GIT_IMPLICIT_WORK_TREE) andGIT_CONFIG_PARAMETERS/GIT_CONFIG_COUNT, whichgit -c foo=bar pushexports into hooks.GIT_CONFIG_GLOBALis not in that list, so it is added explicitly. Without it, a caller can pointremote.origin.urlatvana-com/.githubfrom its own environment and satisfy the origin check against a cache whose real origin is attacker-controlled. Verified on git 2.53.0: with the directory-only scrub the check returned the spoofed URL; withGIT_CONFIG_GLOBALscrubbed it returns the real (attacker) URL and refuses.The
git rev-parse --show-toplevelthat discovers the pushing repo deliberately keeps the inherited environment — that is exactly what it wants.Policy SHA bump
CENTRAL_POLICY_SHAmoves to9990452(the merge of vana-com/.github#2). This is what makes the fix end-to-end: until the pinned policy contained the same fix,install/statuswould fail one layer later in the central scripts.Verification
Against the real merged policy, from a linked worktree with
GIT_DIRset the way git sets it for hooks:Refusing unexpected policy-cache origin, nothing scannedhttps://github.com/attacker/evil.gitandGIT_CONFIG_GLOBALclaimingvana-com/.github, this branch refuses at the origin checkPotential EVM private key detectedThis file is byte-identical across the five remaining repos, so the same patch applies to each.
Assisted-by: AI