Repository navigation
Design TC CFG 016 Version Skew
Status: approved, with the conditions in section 0. The fix (the first of three changes, section 5 "Rollout order") implements it. The spike's throwaway workflows and action stay on their own branch and never reach main; section 2 records what they showed.
These bind the implementation; where an earlier section says otherwise, this section wins.
-
Narrow exception. An unknown pin in a trusted scan drops from high
only when all three hold: the scanner is a release build; embed.json's
versionis strictly greater than the scanner's;tripcord.ymlmatches its recorded digest. Even then every semantic invariant (H1,H2,W4,B4,S1,G1,M1, ...) and removal relative to the base still report high. Positiveembed-inflated-version-hook-loosened(embed.json version 99.0.0 plusonFailure: continue) stays high. -
Pin changes. A pin change relative to the base is always
repinned, high, even when it equals--executing-workflow.--executing-workflowonly accepts a pin the base also has: fork SHAs are reachable from the parent repository, and underpull_requestthe pull request's owntripcord.ymlpicks the workflow that runs, so the flag attests only to itself.base-repinnedstays high. -
Writer witness. A known pin with an unknown render is
changed, high.TestTemplateChangeNeedsRepinenforces "a template change needs a newWorkflowPin" on every pull request (go test ./...in CI), not only in the release gate. -
KnownWorkflowPinsis append-only, starts empty, is guarded by the release gate (TestReleaseGateKnownWorkflowPins), and never holds8b33b1bor6e1d5db. -
initon a release build rejects a--versionolder than itself. -
Fixtures. No existing fixture,
expect.yamlentry, golden,mutations.golden, corpus file,corpus_malicious_test.go, orallowlist.tsvline changes; additions only. The end-to-endTestVersionSkewCIScannerreproduces the six highs. -
Out of v0.
ref: ${{ job.workflow_sha }}and the published-binary option (section 7) are recorded indocs/release-notes.mdas a known gap and future options only. Distribution is not decided here.
TestVersionSkewCIScanner never skips. It runs only under the release
gate (TRIPCORD_RELEASE_GATE=1, make release-gate), and there it fails
with the six highs until the action repin and the WorkflowPin repin
land, so no tag ships before them. Without the gate it logs why and
passes. A synthetic unit test (cmd/tripcord/version_skew_test.go)
covers the fix itself: a simulated older scanner reports no high on a
newer embed, and every security mutation, the inflated version included,
reports high. Moving the end-to-end test into per-pull-request CI,
passing, is the third change.
-
Severity. Tripcord has no
infoseverity (low,medium,high,critical). Every "info" below is implemented as low, with theunverifiedstate. -
Exit code. Sections 3.4 and 6 say a malformed
--executing-workflow"exits 2".scannever returns 2 (it is the hook-block code, seedocs/commands.md), and every configuration error exits 3, so a malformed value, and an olderinit --version, exit 3. -
staleis no longer reported; its rule clause is replaced by one low clause foroutdatedandunverified. The forged-digest positive is nowchangedthroughB4(or the writer witness), still high. -
Main repinned first. While this change was in review, main moved
WorkflowPinfrom6a12795to277066a(still action8b33b1b) and dropped the workflow'spathsfilter.known_renders.jsontherefore holds only277066a. WithKnownWorkflowPinsempty (condition 4), no pin and no render can beoutdatedtoday, so no rule fixture can hold that state.outdatedshares theunverifiedclause, whichembed-manifest-future-schemapins, andTestVersionSkewKnownPinIsOutdatedLowchecks it end to end. Until theWorkflowPinrepin appends6a12795and277066a, a trusted scan reports embeds under either aspin-unknown, high. W2 still applies only to apathsfilter that is present. Since main stopped writingcopilot-setup-steps.ymlwithout--cloud-setup, the scanner at8b33b1balso reports it missing, soTestVersionSkewCIScannernow fails with seven highs, not six. Section 1 and later describe the tree at1571edc. -
Files.
internal/embedded/pins.go(pins,WorkflowRef, version order),invariants.go,renders.goand the generatedknown_renders.json(go run ./scripts/knownrenders), plus the classification incheck.go. -
Workflow template. The
tripcord.ymlrender digest replaces everyuses:value and themain@<short>comment, and the pin check judges every job'suses:on its own. Auses:that is not this repository'stripcord-pr.ymlat a full SHA ispin-malformed, and a workflow with nouses:at all is too. -
New positives are config-item JSON fixtures, one per new
severity_whenclause, soTestSeverityClausesAreCoveredpins each of them:embed-inflated-version-hook-loosened,embed-pin-unknown,embed-pin-malformed, andembed-manifest-future-schema(low). A raw archive would carrybootstrap.sh, whose shebang needs anallowlist.tsvline, and that list only shrinks. -
CI context is plain
scanwith--executing-workfloworGITHUB_ACTIONS=true. A--stagedscan andpreopenare always trusted. -
The action passes
--executing-workflowonly when it builds its own source (nobinaryorrefinput),job.workflow_repositoryisgithub.action_repositoryandvgmartinez/tripcord, andjob.workflow_file_pathis.github/workflows/tripcord-pr.yml.
Here is what runs when a user's pull request is scanned:
- The embed's
tripcord.ymlcallstripcord-pr.yml@W, whereW = embedded.WorkflowPin. -
tripcord-pr.yml@Wcalls.github/actions/tripcord@A, where A is the action pin in that commit'stripcord-pr.yml. - The action runs
CGO_ENABLED=0 go build -trimpath ./cmd/tripcordfromgithub.action_path. That directory is A's tree, delivered as a tarball with no.git.
So the CI scanner is always A's code. The embed was written by init at
some commit H. H is newer than W, because a commit cannot pin itself, and W
is newer than A for the same reason. The CI scanner is therefore always
older than the code that wrote the embed it checks, and it cannot know W.
ownFile and compare (internal/embedded/check.go ~510-616), and
entryState (~652-668), assume the running scanner is the newest Tripcord:
-
wantis this scanner's own render. -
recordedis the digest embed.json records, written by the newerinit. -
got == recorded && got != wantis reported asstale: HIGH, "written by an older Tripcord".
A newer writer always lands in that branch on every surface whose template changed between A and H.
The embed was made with init --embed from main 2ccafcc. The scanner was
built the way the action builds it: git archive 8b33b1b, then
CGO_ENABLED=0 go build -trimpath ./cmd/tripcord.
$ tripcord-A scan . --format text
HIGH TC-CFG-016 .claude/settings.json: Tripcord guard was written by an older Tripcord ... (PreToolUse)
HIGH TC-CFG-016 .claude/settings.json: Tripcord guard was written by an older Tripcord ... (SessionStart)
HIGH TC-CFG-016 .github/hooks/tripcord.json: Tripcord guard was written by an older Tripcord ... (preToolUse)
HIGH TC-CFG-016 .cursor/hooks.json: Tripcord guard was written by an older Tripcord ... (preToolUse)
HIGH TC-CFG-016 .github/workflows/tripcord.yml: Tripcord guard was written by an older Tripcord ...
HIGH TC-CFG-016 .tripcord/bootstrap.sh: Tripcord guard was written by an older Tripcord ...
6 finding(s): 0 critical, 6 high, 0 medium, 0 low; 0 warning(s)
$ tripcord-2ccafcc scan . --format text
0 finding(s): 0 critical, 0 high, 0 medium, 0 low; 0 warning(s)
The same skew appears even between two commits that share a pin. A
2ccafcc scanner reports bootstrap.sh as stale on every committed
TC-CFG-016 embed negative (embed-fresh, embed-claude-only,
embed-crlf-checkout), which current init (3f322e4) wrote, because
#116 changed the bootstrap template. Both commits have WorkflowPin
6a12795.
The forged-digest positive (embed-bootstrap-digest-forged) is caught
today only by the stale state: the edited file equals the forged
recorded digest. Simply downgrading stale would therefore silently drop
that positive. Whatever replaces stale needs a check that does not depend
on the scanner's version (section 3).
- The Copilot setup step.
- The
.gitattributestarget list. - The manifest
schemastring. A newertripcord.embed/v2would be reportedunreadable, which is HIGH. - The harness list.
- The set of hook events. If a newer writer drops an event, the older
scanner reports
missing, which is HIGH. -
bootstrap.sh installandsession-startrunscan --configwith the pinned release binary. Wheninitis newer than--version, that scan is an older scanner judging a newer embed too.
-
Contexts reference,
jobcontext:-
job.workflow_ref: "The full ref of the workflow file that defines the current job. [...] For jobs defined directly in a workflow file, this is the same asgithub.workflow_ref. For jobs defined in a Reuse workflows, this refers to the reusable workflow file. (not available on GitHub Enterprise Server)" -
job.workflow_sha: "The commit SHA of the workflow file that defines the current job. (not available on GitHub Enterprise Server)" -
job.workflow_repositoryandjob.workflow_file_pathare described the same way. - The page's example states the intended use: "This example reusable
workflow uses
job.workflow_repositoryandjob.workflow_shato check out its own source code, rather than the caller's repository." - The availability table lists
jobforjobs.<job_id>.steps.with, so the value can be passed to the action as a step input.
-
-
Contexts reference,
githubcontext:-
github.workflow_ref: "The ref path to the workflow." -
github.workflow_sha: "The commit SHA for the workflow file."
-
-
Reusing workflow configurations,
githubcontext: "When a reusable workflow is triggered by a caller workflow, thegithubcontext is always associated with the caller workflow." Sogithub.workflow_shaandgithub.workflow_refdescribe the caller. -
OpenID Connect reference, custom claims:
-
job_workflow_ref: "For jobs using a reusable workflow, the ref path to the reusable workflow." -
job_workflow_sha: "For jobs using a reusable workflow, the commit SHA for the reusable workflow file."
-
-
OIDC with reusable workflows:
"The
workflow,ref, and other attributes describe the caller workflow, whilejob_workflow_refrefers to the called workflow." -
github.job_workflow_shais not documented anywhere. It is not a context property.
The run is https://github.com/vgmartinez/tripcord/actions/runs/42804705651
(event pull_request, PR #117). It was built as a three-level chain shaped
like production, where each level is pinned by full SHA:
| Level | File | Pinned SHA |
|---|---|---|
| caller (PR head) | .github/workflows/spike-tc-cfg-016-caller.yml |
head ccd46c0, merge ref 702e985
|
| called reusable workflow | .github/workflows/spike-tc-cfg-016-called.yml |
959a98854a23350de2fc6ad8d66fe1308d13b3f1 |
| composite action, used by the called workflow | .github/actions/spike-tc-cfg-016/action.yml |
27fdfbe3ad5952b16dddadc91aaabdf818e96a6b |
Only the called job requested id-token: write, and the caller granted it.
Only the two job_workflow_* claims were decoded, and the token was masked
and never printed.
Exact output of the called job, "called / Echo identity":
--- job context (workflow identity fields) ---
{
"workflow_file_path": ".github/workflows/spike-tc-cfg-016-called.yml",
"workflow_ref": "vgmartinez/tripcord/.github/workflows/spike-tc-cfg-016-called.yml@959a98854a23350de2fc6ad8d66fe1308d13b3f1",
"workflow_repository": "vgmartinez/tripcord",
"workflow_sha": "959a98854a23350de2fc6ad8d66fe1308d13b3f1"
}
--- github context (workflow/sha/ref fields; token excluded) ---
{
"base_ref": "main",
"event_name": "pull_request",
"head_ref": "cursor/tc-cfg-016-version-skew-spike-d737",
"job_workflow_ref": null,
"job_workflow_sha": null,
"pr_head_sha": "ccd46c0853180d21c851a6c4d5320880761a33d6",
"ref": "refs/pull/117/merge",
"repository": "vgmartinez/tripcord",
"sha": "702e98537ea6071d2b74396203acd3480da48161",
"workflow": "spike-tc-cfg-016-caller",
"workflow_ref": "vgmartinez/tripcord/.github/workflows/spike-tc-cfg-016-caller.yml@refs/pull/117/merge",
"workflow_sha": "702e98537ea6071d2b74396203acd3480da48161"
}
--- runner env ---
GITHUB_WORKFLOW_SHA=702e98537ea6071d2b74396203acd3480da48161
GITHUB_WORKFLOW_REF=vgmartinez/tripcord/.github/workflows/spike-tc-cfg-016-caller.yml@refs/pull/117/merge
GITHUB_SHA=702e98537ea6071d2b74396203acd3480da48161
GITHUB_REF=refs/pull/117/merge
{
"job_workflow_ref": "vgmartinez/tripcord/.github/workflows/spike-tc-cfg-016-called.yml@959a98854a23350de2fc6ad8d66fe1308d13b3f1",
"job_workflow_sha": "959a98854a23350de2fc6ad8d66fe1308d13b3f1"
}
--- composite: job context ---
{
"workflow_file_path": ".github/workflows/spike-tc-cfg-016-called.yml",
"workflow_ref": "vgmartinez/tripcord/.github/workflows/spike-tc-cfg-016-called.yml@959a98854a23350de2fc6ad8d66fe1308d13b3f1",
"workflow_repository": "vgmartinez/tripcord",
"workflow_sha": "959a98854a23350de2fc6ad8d66fe1308d13b3f1"
}
--- composite: github.action_* ---
github.action_ref=27fdfbe3ad5952b16dddadc91aaabdf818e96a6b
github.action_repository=vgmartinez/tripcord
env GITHUB_WORKFLOW_SHA=702e98537ea6071d2b74396203acd3480da48161
env GITHUB_WORKFLOW_REF=vgmartinez/tripcord/.github/workflows/spike-tc-cfg-016-caller.yml@refs/pull/117/merge
Which value is which:
| Candidate | Value seen | Equals |
|---|---|---|
job.workflow_sha, in the workflow and inside the composite action |
959a988 |
called workflow |
job.workflow_ref |
...called.yml@959a988 |
called workflow |
OIDC job_workflow_sha
|
959a988 |
called workflow |
OIDC job_workflow_ref
|
...called.yml@959a988 |
called workflow |
github.workflow_sha, GITHUB_WORKFLOW_SHA
|
702e985 |
caller (the PR merge commit, not even the head ccd46c0) |
github.workflow_ref, GITHUB_WORKFLOW_REF
|
...caller.yml@refs/pull/117/merge |
caller |
github.sha |
702e985 |
caller's merge commit |
github.job_workflow_sha, github.job_workflow_ref
|
null |
does not exist |
github.action_ref |
27fdfbe |
the composite action (A), not the workflow |
Conclusion. job.workflow_sha is a documented and observed source for
the SHA the called workflow runs at. Inside the composite action it still
names the reusable workflow. It needs no extra permission, unlike the OIDC
claim, which needs id-token: write.
Limits of the spike:
- It covers github.com only: the
job.workflow_*properties are not available on GHES. - The caller used a full SHA. Calls by branch or tag were not exercised, and the design rejects those pins anyway.
- Caller and callee were in the same repository.
Even so, the value is self-attestation. It is reported to the job that is running, and if W is fork code, the scanner reading it is fork code too (section 5).
-
Version-independent checks decide HIGH. These are checks whose
answer does not depend on which Tripcord wrote the embed:
- semantic invariants (section 3.2);
- consistency with the manifest the writer produced;
- base-relative changes.
- Version-dependent checks never produce HIGH for an unknown, possibly newer render. These are exact-render comparisons against this scanner's templates.
-
Unverifiable results degrade, never vanish. They become
info(orlowfor a known older render or pin), with a message telling the user to scan locally with the latest Tripcord.
The invariants live in internal/embedded/invariants.go. Each one has a
stable id. An invariant may be tightened in a later version but never
loosened. A test pins that rule: TestInvariantsHoldForInit checks that
current init output satisfies every invariant, and the invariant table is
append-only (checked against origin/main like KnownWorkflowPins).
Loosening one would make older scanners flag newer embeds, which is exactly
this bug, so it is a breaking change.
| Id | Surface | Invariant |
|---|---|---|
B1 |
bootstrap.sh |
Line 1 is #!/bin/sh, and set -eu comes before any other command. |
B2 |
bootstrap.sh |
Exactly one TRIPCORD_VERSION='<embed.json version>'. |
B3 |
bootstrap.sh |
For each platform in embed.json sha256, exactly one arm <platform>) printf '%s\n' '<sum>' ;;, and no other 64-hex literal. |
B4 |
bootstrap.sh |
The checksum gate if [ "$got" != "$want" ]; then is present and its next line starts with fail . |
H1 |
each wired hook harness | The pre-tool event holds an entry that runs .tripcord/bootstrap.sh with hook (runsGuard). |
H2 |
Claude PreToolUse
|
That entry's matcher is *, and its command hook has "onFailure": "block". |
H3 |
Cursor preToolUse
|
"failClosed": true, with no matcher that narrows it. |
H4 |
Copilot preToolUse
|
type: command, cwd: ".", timeoutSec >= 60. A timed-out Copilot hook fails open. |
H5 |
all hook harnesses | The guard command passes --on-failure block. |
H6 |
all hook harnesses | No disableAllHooks: true in the shared file. This is the existing disable-all clause. |
W1 |
tripcord.yml |
on contains pull_request and none of pull_request_target or workflow_run. |
W2 |
tripcord.yml |
on.pull_request.paths, when set, is a superset of .tripcord/**, .claude/**, .cursor/**, .github/**. The set only grows. |
W3 |
tripcord.yml |
Exactly one job uses this repository's tripcord-pr.yml at a pin, and that job has no if:. The pin is judged by section 3.4. |
W4 |
tripcord.yml |
with.fail-on is present and is one of low, medium, high. |
W5 |
tripcord.yml |
with sets none of binary, ref, or path (other than .). This is a denylist: new inputs stay allowed. |
S1 |
Copilot setup step |
run is bash .tripcord/bootstrap.sh install with no ||, ;, &, |, or newline after it, and the step has no continue-on-error: true and no if:. |
G1 |
.gitattributes |
Every gitattributesTargets() path resolves text eol=lf (gitattributesOK). The target list only grows. |
M1 |
embed.json | The manifest parses and records every surface it claims. A recorded entry that is absent is missing; one the manifest does not record is not. |
B1-B4 cover the bootstrap edits the positives make and the obvious
bypasses. They cannot prove that an arbitrary shell script is safe. That
residual risk is covered by the writer-witness rule (section 3.3), and in
pull requests by the base comparison.
For bootstrap.sh, tripcord.yml, each hook entry, and the Copilot step,
compare and entryState become the following decision. Here got is the
content digest and recorded is the embed.json digest.
-
got == current render: OK, as today. -
gotis inknownRenders, the compiled historical renders (section 3.5):outdated, low, "an older Tripcord wrote this; reruninit --embed --force". This replacesstale, which no committed fixture uses except the forged-digest case, handled in step 4. -
got != recordedand step 2 did not match:changed, high. This is version-independent, because everyinitwrites a file equal to the digest it records, so a mismatch means an edit afterinit. -
got == recorded, the render is unknown, and the tripcord.yml pin is in the closed set (writer witness):changed, high, with payloadinvariant: "witness". A known pin means a writer this scanner knows, whose renders it has compiled. This holds because, from this change on, every template change bumpsWorkflowPin(TestTemplateChangeNeedsRepin, section 3.5). This step keeps today's strength against forged digests in any scan whose pin is known. -
got == recorded, the render is unknown, and the pin is unknown:unverified, info, with payloadreason: "unknown-render"and a fix: "This file was likely written by a newer Tripcord than this scanner; scan locally with the latest Tripcord." - In every case, a failing semantic invariant (section 3.2) reports
changed, high, with payloadinvariant: "<id>". It is merged into the item for the same subject, so each subject still has one item.
Three related rules:
-
Unknown structure. A manifest
schemaoftripcord.embed/vNwith N > 1, a harness the scanner does not know, or a hook event the manifest records that the scanner does not know:unverified, info. The semantic and pin checks still run, so bumping the schema does not dodge them. -
Missing entries.
missingis HIGH only for what the manifest records (M1), plus the floor every version writes: bootstrap.sh, embed.json, tripcord.yml, theH1entry per wired harness, andG1. An event a newer writer dropped and did not record isunverified, info. -
States that do not change:
removed,dropped,repinned,weakened,local-disabled,local-policy,unreadable(unparseable), and the leftover path. They are already version-independent.base-repinnedstays HIGH.
Requirement (1) holds for every render surface. A newer writer always
gives got == recorded. Its pin is unknown to an older scanner, because
template changes require a new pin, so it lands in step 5 (info) unless
an invariant fails.
This applies to jobs.*.uses of tripcord.yml. The closed set is
{WorkflowPin} ∪ KnownWorkflowPins (section 3.5).
| Pin | Trusted scan (local scan, pre-commit --staged) |
CI scan |
|---|---|---|
Not this repository's .github/workflows/tripcord-pr.yml, or a ref that is not 40 lowercase hex (short SHA, main, refs/heads/..., v0.1.0) |
pin-malformed, high
|
pin-malformed, high
|
== WorkflowPin |
OK | OK |
In KnownWorkflowPins
|
outdated, low
|
outdated, low
|
== --executing-workflow SHA |
(the flag is CI-only) | OK |
| Any other 40-hex (unknown, or a fork-network SHA) |
pin-unknown, high
|
unverified, info ("cannot verify pin in CI; scan locally with the latest Tripcord") |
Flag. The proposed flag is tripcord scan --executing-workflow <owner>/<repo>/<path>@<sha>.
- The value is
${{ job.workflow_repository }}/${{ job.workflow_file_path }}@${{ job.workflow_sha }}, set by the composite action, which can readjob.*directly as the spike shows. - The action passes it only when
job.workflow_repositoryisgithub.action_repositoryandjob.workflow_file_pathis.github/workflows/tripcord-pr.yml. A user who calls the action directly gets no flag, and GHES leaves the value empty. - The scanner rejects (exit 2, config error) a value whose repository is not
project.Repository, whose path is not.github/workflows/tripcord-pr.yml, or whose SHA is not 40 lowercase hex. A misconfiguration therefore fails loudly. - The flag marks the scan as a CI scan. It can only accept a pin equal to its SHA. It never upgrades or suppresses anything else.
- It is a flag only, never read from a policy file or the repository.
Scan context. CheckOptions gains Context (Trusted is the zero
value, or CI) and Executing *WorkflowRef. cmd/tripcord selects CI
when --executing-workflow is given or GITHUB_ACTIONS=true. Both are set
by the runner or the workflow, never by the scanned tree. The tests' own
TestMain already unsets GITHUB_ACTIONS, and the fixture helpers call
embedded.Check with zero options, so fixtures stay trusted and unchanged.
Base mode (optional addition). A change to the pin between base and
head reports the existing repinned state, with subject workflow-pin
and HIGH severity. It is the same review a binary re-pin gets. No existing
JSON fixture changes the workflow pin, so none changes.
Conflict between requirements (1) and (5), stated explicitly. In a trusted scan by a scanner older than the writer, the newer pin is unknown, so (5) says HIGH while (1) says no HIGH for a newer embed. Offline, nothing distinguishes "a newer writer" from "a forged pin plus a forged embed.json". The recommended resolution needs sign-off:
-
pin-unknowndrops tounverified/info in a trusted scan only when all of these hold:- the scanner is a release build;
- embed.json
versionis valid semver and strictly greater than the scanner's own version; - tripcord.yml matches its recorded digest.
Lying about
versiongains nothing at hook time, becausebootstrap.shonly runs a cached binary whose SHA-256 matches the pinned sum (B3andB4), and a nonexistent version fails closed. -
Otherwise (5) wins:
pin-unknownstays HIGH, with the fix text "If this embed was written by a newer Tripcord than this scanner (vX), upgrade and rescan; otherwise this is not a Tripcord commit." -
To keep the remaining case rare,
init --embedon a release build should refuse a--versionolder than itself. Otherwise the pinned binary's ownscan --configinbootstrap.shis an older trusted scanner.
internal/embedded/pins.go:
// KnownWorkflowPins are earlier values of WorkflowPin, oldest first.
// A repin PR appends the WorkflowPin it replaces, in the same change;
// entries are never edited or removed. A pin here is accepted as
// outdated (low), never as current. TestKnownWorkflowPinsShape checks
// the format; TestReleaseGateKnownWorkflowPins checks each against main.
var KnownWorkflowPins = []string{
// Seeded by the fix PR as empty; the first repin PR appends
// "6a1279565e9e41e9dec163e6bedf07f2647a2c67" (main@6a12795).
// 8b33b1b and 6e1d5db are deliberately absent: their
// tripcord-pr.yml pins an action without the embed check.
}
// WorkflowRef is a parsed --executing-workflow value.
type WorkflowRef struct{ Repository, Path, SHA string }
// PinState is the verdict on a tripcord.yml pin.
type PinState int
const (
PinCurrent PinState = iota // == WorkflowPin
PinExecuting // == CheckOptions.Executing.SHA (CI only)
PinKnown // in KnownWorkflowPins: outdated (low)
PinUnknown // 40-hex, in neither: high (trusted) / info (CI)
PinMalformed // not tripcord-pr.yml@<40-hex>: high
)
func ClassifyPin(uses string, executing *WorkflowRef) PinStateinternal/embedded/known_renders.go is generated by go run ./scripts/knownrenders and must not be edited by hand:
type renderSet struct {
bootstrapTemplate []string // sha256 of bootstrap.sh with the TRIPCORD_VERSION line and sum arms replaced by placeholders
workflowTemplate []string // sha256 of tripcord.yml with the pin and its main@ comment replaced
hooks map[string][]string // "<harness>/<event>" -> HookEntry.SHA256
copilotStep []string
}
// knownRenders maps each pin in {WorkflowPin} ∪ KnownWorkflowPins to
// every render an init that wrote that pin produced.
var knownRenders = map[string]renderSet{ /* generated */ }The generator walks every main commit from 8b33b1b onward. At each one it
builds cmd/tripcord, runs init --embed --harness claude,cursor,copilot
with a fixed dummy pin, normalizes the output, and groups the result by that
commit's WorkflowPin. The pin 6a12795 already maps to several templates
(c8e5bdd, 85a380a, f81d1bf, ff4b401, 3f322e4). That is fine,
because it is a set.
Repin PR procedure.
- Set
WorkflowPinto the new SHA. - Append the old SHA to
KnownWorkflowPins. - Run
go run ./scripts/knownrenders. - Run
UPDATE_GOLDEN=1 go test ./cmd/tripcord -run TestCFG016FixturesMatchInit, which rewrites the pin inside the fixtures, as every repin does today. - Update the
docs/github-action.mdpin.
Tests that keep it honest.
-
TestKnownWorkflowPinsShape(always runs): every entry is 40 lowercase hex, entries are unique,WorkflowPinis not in the list, andknownRenderskeys equal{WorkflowPin} ∪ KnownWorkflowPins. -
TestTemplateChangeNeedsRepin(needs history): the current render must be inknownRenders[WorkflowPin]as committed onorigin/main. Changing a template without a new pin fails with "template changed: repin WorkflowPin". -
TestReleaseGateKnownWorkflowPins(TRIPCORD_RELEASE_GATE=1, next toTestReleaseGatePinnedActionHasEmbedCheck). For every entry, and forWorkflowPin, it checks that:- the commit is in the clone;
-
merge-base --is-ancestor <pin> origin/mainholds; - the commit descends from
embedCheckMinimum; - its
tripcord-pr.ymlexists and pins an action whose tree hasfunc Check(and thebaseinput (reusingactionPins); - the list is ordered, with each entry an ancestor of the next and of
WorkflowPin; - the list is a prefix-extension of
origin/main's list (append-only), and the oldknownRendersentries are byte-identical.
- Add a
lowclause forstate == "outdated". - Add an
infoclause forstate == "unverified", titled "Tripcord could not verify this part of the guard". Its fix is "scan locally with the latest Tripcord (tripcord scan); this scanner is older than the embed or runs in CI". - Add
highclauses forpin-unknownandpin-malformed. - Keep the existing HIGH clauses for
missing,changed,unreadable,removed,dropped,repinned,weakened,local-disabled, andlocal-policy. - Leave
staledefined but unused, or remove it.
Every positive keeps its single severity, high, and expect.yaml is
untouched. "Exact" means step 3 of section 3.3 (got != recorded), which
is version-independent. The table lists the semantic check that also
catches each mutation when an attacker forges embed.json to match.
| Positive | Today (current scanner) | Version-independent detection after the change |
|---|---|---|
claude-disable-all-hooks |
disableAllHooks clause |
H6, unchanged (not an embed check) |
copilot-hooks-file-disable-all-hooks |
disableAllHooks |
H6, unchanged |
copilot-settings-disable-all-hooks |
disableAllHooks |
H6, unchanged |
gemini-hooks-config-disabled |
hooksConfig.enabled false | unchanged (not an embed check) |
embed-claude-disable-all-hooks |
disableAllHooks | H6 |
embed-claude-wiring-removed (guard removed) |
missing (PreToolUse, SessionStart) |
M1 (manifest records both) + H1
|
embed-claude-only-wiring-removed |
missing ×2 |
M1 + H1
|
embed-cursor-wiring-removed |
missing ×2 |
M1 + H1
|
embed-copilot-wiring-removed |
missing ×2 |
M1 + H1
|
embed-claude-not-tripcord |
missing PreToolUse |
H1 (no entry runs bootstrap.sh hook) |
embed-cursor-not-tripcord |
missing preToolUse |
H1 |
embed-copilot-not-tripcord |
missing preToolUse |
H1 |
embed-claude-hook-loosened (onFailure continue) |
changed |
exact + H2
|
embed-workflow-changed (fail-on critical) |
changed |
exact + W4
|
embed-bootstrap-changed (bootstrap: checksum gate → false) |
changed |
exact + B4
|
embed-bootstrap-digest-forged (forged digest) |
stale (the only thing catching it today) |
B4 + writer witness (step 4: known pin, unknown render) |
embed-copilot-step-changed (install || true) |
changed |
exact + S1
|
embed-gitattributes-weakened (-text) |
changed |
G1 (already semantic) |
embed-gitattributes-removed |
missing |
G1 floor |
embed-bootstrap-missing |
missing |
floor (bootstrap.sh) |
embed-manifest-unreadable |
unreadable |
unchanged ({ does not parse) |
embed-guard-removed-workflow-left |
leftover: missing bootstrap and manifest |
unchanged (leftover path) |
embed-leftover-claude-hook |
leftover: missing
|
unchanged |
base-guard-removed.json (guard removed) |
removed |
unchanged (base-relative) |
base-embed-removed.json |
removed |
unchanged |
base-harness-dropped.json |
dropped |
unchanged |
base-repinned.json |
repinned |
unchanged, stays HIGH |
base-policy-weakened.json |
weakened |
unchanged |
local-claude-disable-all-hooks.json |
local-disabled |
unchanged |
local-copilot-disable-all-hooks.json |
local-disabled |
unchanged |
base-local-disable-all-hooks.json |
local-disabled |
unchanged |
local-policy-tracked.json |
local-policy |
unchanged |
base-local-policy-tracked.json |
local-policy |
unchanged |
Why no fixture changes:
- The fix PR changes neither a template nor
WorkflowPin, soTestCFG016FixturesMatchInitstill matches. - Every committed fixture is a current render with the current pin, so the
new
outdated,unverified, and pin states never fire on them. - Semantic results are merged into the existing per-subject item. They add
the
invariantpayload key only in steps 4 and 5, which no JSON fixture reaches. - The forged-digest positive moves from
staletochanged, and both are HIGH. That positive is a txtar fixture checked by severity only.
-
In-workflow checking is self-attestation. The embed's
tripcord.ymlcomes from the pull request:pull_requestruns the merge commit's workflow file. A PR can point it at this repository'stripcord-pr.ymlat a fork-network SHA or anywhere else, and then the scanner itself is that code.--executing-workflowonly proves "the pin equals what is running", and the semantic checks only bind an honest scanner. The real defenses live outside the PR:- trusted scans (local and pre-commit), which apply the closed set;
- base-mode
repinnedon review; - CODEOWNERS on
.tripcord/**and.github/workflows/tripcord.yml; - a GitHub ruleset "required workflow", whose workflow does not come from the PR.
-
job.workflow_*is not available on GHES. There the CI path falls back to the closed set, and unknown pins areinfo. -
B1-B4cannot prove that an arbitrary script is safe. In CI, with the pin unknown to the scanner, a forged-digestbootstrap.shthat keepsB1-B4is onlyinfo. A trusted scan catches it through the writer witness orpin-unknown. - Rollout. Embeds pinned to
6a12795keep running action8b33b1band keep failing until the user rerunsinit --embed --forceafter the repin chain below. The fix PR itself cannot help those embeds.
-
Fix PR (F): checker, invariants, rule clauses,
KnownWorkflowPins,knownRenders, the action's--executing-workflowplumbing, and tests. No template or pin change. -
Repin PR (G):
tripcord-pr.yml's action pin set to F. -
Repin PR (H):
WorkflowPinset to G,6a12795appended toKnownWorkflowPins, and fixtures regenerated.
The e2e in section 6 passes from H on.
The tests go in new files: internal/embedded/check_skew_test.go,
cmd/tripcord/skew_e2e_test.go, and new fixtures only if they carry a
single severity.
-
Outdated pin: the pin is the last entry of
KnownWorkflowPins, with the digest rewritten asinitwould. Expect exactly oneoutdated(low), trusted and CI. -
Unknown pin: a random 40-hex SHA.
- Trusted:
pin-unknown, high. - CI without the flag:
unverified, info. - CI with the flag equal to the pin: no item.
- CI with the flag not equal:
unverified, info. - The release-build refinement from section 3.4, if adopted: the version
is greater than the scanner's, so
unverified, info.
- Trusted:
-
Short, branch, and tag pins: a table of
6a12795, a 39-hex SHA, uppercase hex,main,refs/heads/main,v0.1.0, another owner'stripcord/...atWorkflowPin, and.../tripcord-pr-comment.yml@.... Expectpin-malformed, high, in both contexts. -
Fork SHA: a 40-hex SHA that is a valid commit only in a fork
(constant).
- Trusted:
pin-unknown, high. - CI with the flag equal to it: accepted. The test names this as the documented self-attestation limit.
- Base mode:
repinned, high.
- Trusted:
-
Flag parsing (cmd): a wrong repository, wrong path, non-hex SHA, or
an empty
@exits 2. A valid value sets the CI context. -
Newer embed, older scanner, one subtest for each of the 6 surfaces:
Claude
SessionStart, ClaudePreToolUse, CursorpreToolUse, CopilotpreToolUse,tripcord.yml, andbootstrap.sh.- Setup: apply a benign "future" change to that surface, such as an extra
harmless key in the hook entry, an extra comment line in bootstrap.sh,
or an extra
paths:entry in tripcord.yml. Then rewrite the embed.json digest the way a newerinitwould, and set the pin to an unknown 40-hex SHA. - Assert, in CI with and without the flag: no high item for that
subject, exactly one
unverifiedinfo. - Variant: the same change plus an invariant break (
H2,H3,H4,H5,W4,B4). Expectchanged, high, with theinvariantset. - Variant: the same benign change with a known pin. Expect
changed, high (writer witness).
- Setup: apply a benign "future" change to that surface, such as an extra
harmless key in the hook entry, an extra comment line in bootstrap.sh,
or an extra
-
Older embed, newer scanner: take a render from
knownRendersthat is not current. Expectoutdated, low. For a pre---on-failurehook render, also expectH5, high. -
Unknown structure: schema
tripcord.embed/v2isunverifiedinfo and notunreadable. A harness or event the scanner does not know isunverifiedinfo. A recorded event that is absent ismissing, high. An unrecorded absent event isunverifiedinfo. -
Invariant contract:
TestInvariantsHoldForInitchecks every harness combination, andTestInvariantsAppendOnlychecks againstorigin/main. -
E2E
TestVersionSkewCIScanner(TRIPCORD_RELEASE_GATE=1and a CI job with full history). It reproduces the 6 HIGH today and passes after step 3 of the rollout:- Build
cmd/tripcordfrom this tree. Runinit --embed --version 0.1.0 --sha256 linux-x64=<64 hex>in a temporary git repository. - Read
git show <WorkflowPin>:.github/workflows/tripcord-pr.yml, and take itsactions/tripcord@<A>withactionPins. - Run
git archive A, extract it with no.git, and runCGO_ENABLED=0 go build -trimpath ./cmd/tripcordinside it: exactly what the action does. - Run that binary with
scan <repo> --format json, withGITHUB_ACTIONS=true. Add--executing-workflownaming this repository'stripcord-pr.ymlatWorkflowPinwhenscan --helplists the flag. - Assert that no TC-CFG-016 finding is high or critical. Today this
fails with exactly the 6 subjects in section 1. After F, G, and H it
passes, with at most
unverifiedinfo.
- Build
Distribution is Victor's decision, so this is presented as an option only.
Is it the clean path? Partly. It removes "CI builds A from source", but version skew comes from which version CI runs, not from how it gets it. A published binary chosen by W or A is still older than the writer. The variant that actually closes the gap is this:
- CI runs the release the embed itself pins: embed.json
versionplus itslinux-x64SHA-256. - For a pull request, the pin is taken from the base revision's embed.json, so the PR cannot choose it. The head's pin is used only when the base has no embed.
- The download comes from the project's releases and is verified against that digest before it runs.
That is the same binary the hooks run. When init and --version are the
same release, which is the normal case, the scanner and the writer are the
same version, and the degrade rules above only cover the remaining edge
cases.
Advantages:
- Same bits as the hooks, and reproducible.
- No Go toolchain in CI, and faster.
- No fork-network source build.
- Provenance can be checked with GitHub artifact attestations or SLSA.
Costs and risks:
- It needs published releases with checksums and signing or attestations (release infrastructure, key custody).
- CI needs network egress to the release host, which rules out air-gapped runners and GHES without a mirror.
- A head-only pin (first PR) lets the PR choose an older official release. That calls for a minimum-version floor compiled into W.
- The embed must pin
linux-x64(today--sha256is per platform and optional per platform). - Unreleased main cannot be tested this way. Keep the source-build path for
this repository's own CI (
./.github/actions/tripcord). - It still does not remove the self-attestation limit in section 5.
A smaller step that needs no release infrastructure: tripcord-pr.yml
passes ref: ${{ job.workflow_sha }} to the action, which already supports
ref. The action then builds W instead of A, which narrows the gap from
"A behind" to "one pin behind". It does not close the gap, because W cannot
contain its own SHA.
This wiki is generated from docs/ on main by cmd/wikigen. Do not edit it here: change docs/ and open a pull request. Apache-2.0.
Start
Commands
CI and hooks
Configuration
Adapters
- Claude Code
- Codex
- Cursor
- GitHub Copilot
- Gemini CLI
- OpenCode
- Windsurf
- Devin
- Dev Container
- Shared Files
Project