There's a default in actions/checkout\ that most teams never change β and that quietly leaves a GitHub token sitting in a readable file for every subsequent step in the job.
The fix is one line. The reasoning is worth understanding.
The Setting
- uses : actions/checkout@v4 with : persist-credentials : false # default is true ~~~
By default (\`persist-credentials : true \`), the checkout action writes a git credential config file containing your GitHub token to \`$RUNNER_TEMP\`. That file persists for the lifetime of the job.
## What the File Looks Like
The checkout action creates a file at \`$RUNNER_TEMP/git-credentials-<UUID>.config\`:
~~~ini [ http "https : //github.com/" ] extraheader = AUTHORIZATION : basic <Base64-encoded-string> ~~~
The Base64 string decodes to \`x-access-token:<GITHUB_TOKEN>\`. It's not encrypted. It's not write-protected.β¦