Skip to content

Warn when the job token is readable by the cifail image (#39) - #42

Merged
SebHenn merged 1 commit into
mainfrom
fix/issue-39-persisted-credentials
Oct 24, 2026
Merged

SebHenn merged 1 commit into
mainfrom
fix/issue-39-persisted-credentials

Conversation

@SebHenn

@SebHenn SebHenn commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Fixes #39.

The action runs the image with the whole workspace mounted (-v "$PWD:/work"). actions/checkout v5 and earlier persist the job token in .git/config unless given persist-credentials: false, so for those users the image can read the GITHUB_TOKEN.

What changes

  • action.yml: before it starts the container, the step checks .git/config and ./*/.git/config (for path: checkouts one level down) for an extraheader. If it finds one, it emits a ::warning:: that names the file and the fix. It warns rather than hiding .git, because the container needs the workspace: it reads the log, writes the reports there, and cifail runs git for correlation.
  • README: the main example now starts with actions/checkout@v7 and persist-credentials: false, followed by a note on why.
  • A ### Security entry in the changelog.

Why checkout v6+ does not warn

I checked src/git-auth-helper.ts at checkout v7.0.1. It writes the token to $RUNNER_TEMP/git-credentials-<uuid>.config, and .git/config gets only includeIf.gitdir:….path entries pointing there. $RUNNER_TEMP is not mounted, and the include path contains no extraheader. So the check fires exactly when the token is inside the workspace.

Tested

The step script was extracted the way ci.yml does and run under bash --noprofile --norc -e -o pipefail, with a stub docker, in a scratch workspace:

Workspace Warnings
.git/config with no credential 0
.git/config with [http "https://github.com/"] extraheader = … (checkout ≤ v5) 1
.git/config with only a v6-style includeIf → git-credentials-<uuid>.config 0
plus sub/.git/config with extraHeader (mixed case) 1 (for sub/; the root has none)
no .git at all 0

shellcheck passes on the script, and check-versions.sh passes.

🤖 Generated with Claude Code

The action mounts the workspace into the container, and actions/checkout
v5 and earlier persist the job token in .git/config by default. The step
now warns when the workspace's .git/config (or a path: checkout's, one
level down) holds an extraheader. Checkout v6+ only writes an includeIf
to a file under $RUNNER_TEMP, so it does not trigger. The README example
checks out with persist-credentials: false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SebHenn
SebHenn merged commit c1c2360 into main Oct 24, 2026
7 checks passed
@SebHenn
SebHenn deleted the fix/issue-39-persisted-credentials branch October 24, 2026 14:16
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.

The action mounts the workspace read-write, so a token persisted by checkout v5 or earlier is readable by the image

1 participant