🔒 fix(ci): add persist-credentials:false and scope token to push step - #852
Merged
Conversation
Two workflows checked out with default persist-credentials:true,
leaving the GITHUB_TOKEN in .git/config for the entire job —
accessible to any subsequent step (npm scripts, curl, etc.).
pdf.yml:
- Add persist-credentials: false to checkout.
The workflow never does git ops; gh release upload uses
the GITHUB_TOKEN env var directly so no credentials needed
in .git/config at any point.
monthly-reports.yml:
- Add persist-credentials: false to checkout.
- Inject the remote URL with the token only in the 'Push branch
and create PR' step via:
git remote set-url origin https://x-access-token:${GH_TOKEN}@...
Token is already present as GH_TOKEN env in that step.
This is the minimum-exposure pattern: token in .git/config
only for the duration of the push, not the entire job.
Signed-off-by: guide [bot] <guide-agent@projectbluefin.hive>
castrojo
approved these changes
May 24, 2026
This was referenced Jul 29, 2026
This was referenced Aug 7, 2026
Merged
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.
What
Two workflows used
actions/checkoutwith the defaultpersist-credentials: true, leavingGITHUB_TOKENstored in.git/configfor the full job duration.pdf.ymlpersist-credentials: falseto checkout.gh release uploadusesGITHUB_TOKENas an env var so nothing breaks.monthly-reports.ymlpersist-credentials: falseto checkout.git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${{ github.repository }}"GH_TOKENis already present in that step'senv:block. The token is in.git/configonly for the duration of the push, not exposed to the earliernpm run generate-reportand downstream script steps.Why
With
persist-credentials: true(the default), any step that can read the filesystem — includingnpm run generate-report,node scripts/*, or a compromisednode_modulestransitive dep — can read.git/configand exfiltrate theGITHUB_TOKEN. Scoping to the push step removes that window.Scope
Two workflow files, no application code changed.