Skip to content

GH Actions: do not persist credentials#363

Merged
sirbrillig merged 1 commit intosirbrillig:2.xfrom
jrfnl:feature/ghactions-do-not-persist-credentials
Mar 11, 2026
Merged

GH Actions: do not persist credentials#363
sirbrillig merged 1 commit intosirbrillig:2.xfrom
jrfnl:feature/ghactions-do-not-persist-credentials

Conversation

@jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Mar 10, 2026

By default, using actions/checkout causes a credential to be persisted in the checked-out repo's .git/config, so that subsequent git operations can be authenticated.

Subsequent steps may accidentally publicly persist .git/config, e.g. by including it in a publicly accessible artifact via actions/upload-artifact.

However, even without this, persisting the credential in the .git/config is non-ideal unless actually needed.

Remediation

Unless needed for git operations, actions/checkout should be used with persist-credentials: false.

If the persisted credential is needed, it should be made explicit with persist-credentials: true.

This has now been addressed in all workflows.

Refs:

> By default, using `actions/checkout` causes a credential to be persisted in the checked-out repo's `.git/config`, so that subsequent `git` operations can be authenticated.
>
> Subsequent steps may accidentally publicly persist `.git/config`, e.g. by including it in a publicly accessible artifact via `actions/upload-artifact`.
>
> However, even without this, persisting the credential in the `.git/config` is non-ideal unless actually needed.
>
> **Remediation**
>
> Unless needed for `git` operations, `actions/checkout` should be used with `persist-credentials: false`.
>
> If the persisted credential is needed, it should be made explicit with `persist-credentials: true`.

This has now been addressed in all workflows.

Refs:
* https://unit42.paloaltonetworks.com/github-repo-artifacts-leak-tokens/
* https://docs.zizmor.sh/audits/#artipacked
@jrfnl jrfnl added the github_actions Pull requests that update GitHub Actions code label Mar 10, 2026
@sirbrillig
Copy link
Owner

TIL!

@sirbrillig sirbrillig merged commit dc2e37d into sirbrillig:2.x Mar 11, 2026
33 checks passed
@jrfnl jrfnl deleted the feature/ghactions-do-not-persist-credentials branch March 11, 2026 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

github_actions Pull requests that update GitHub Actions code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants