You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Remove persist-credentials or change the default to false #485
Currently one has to resort to explicitly specifying persist-credentials: false to avoid the credentials being persistent. My understanding is that persisting the credentials gives every step in the job that occurs after actions/checkout@v2 implicit access to the token. This is not what people expect and this leads people to write jobs that expose their repo to more risk than they otherwise would.
I propose the persist-credentials feature be removed completely and then v3 be released. Otherwise, if that's not practical, then at least the default should be changed to false.
Reacted by Jack Lloyd, Michael McLoughlin, Alex Gaynor, Maximilian Hils, Daniel Micay, Tom Chen, Yuta Kawabe, RA80533, Brian Romanowski, Harmen Stoppels and 169 more
Reacted by Jayden Seric, Marcel Richter, Pawel Chojnacki, Vipul Gupta, Michele Degges, Mert Şişmanoğlu, Frog Chen, Antonio Ventilii, andig, Guillaume and 6 more
I can't believe the default is to persist credentials and expose them to other jobs :( this is a major security issue.
Just as a heads up for anyone stumbling upon this issue:
persist-credentials: false is only relevant when you use ssh authentication, because
GITHUB_TOKEN is always exposed to all jobs, and by default has write access to your repo.
So if you want to harden security, apart from setting persist-credentials: false for ssh auth, make sure that GITHUB_TOKEN auth has no write permission to your repo.
Agreed this seems a severe security issue, because it means any workflow using actions/checkout basically leaks the token to any process/action in that workflow which can just read it from .git/config.
@haampie IIUC it is a problem also with no ssh authentication (the default). The GitHub token is given only to this action and maybe a few other actions/* actions (default: ${{ github.token }} only work for those AFAIK), but is otherwise given to no other action unless done explicitly (like with: token: ${{ github.token }}/${{ secrets.GITHUB_TOKEN }}).
The token is not in the environment.
In other words, actions/checkout leaks the token to .git/config, making it very easy to read for anything running inside the workflow.
If the token was not written to .git/config, then I think stealing the GitHub token would require (one of):
passing the token explicitly to some action in the workflow and that action gets compromised
actions/checkout gets compromised
compromise the workflow definition to e.g. print the token
So, depending on whether the token is explicitly passed to some action:
If no, it would be safe by default with this change or with persist-credentials: false, regardless of the token permissions. A workaround is to set token permissions
I guess GitHub sees setting token permissions as the more general solution.
If so, fine, but then the default should be secure and so the default workflow permissions should be just contents: read.
If the workflow uses actions/checkout and does not pass the optional parameter persist-credentials as false, it makes it even worse. The default for the parameter is true. It means that in any subsequent steps any running code can simply read the stored repository token from the disk.
changed the title [-]Release a new version v3 with `persist-credentials` removed or `false` by default[/-][+]Remove `persist-credentials` or change the default to `false`[/+]on Sep 5, 2023
PyTorch had several workflows that used the actions/checkout step with a GITHUB_TOKEN that had write permissions. For example, by searching through workflow logs, we can see the periodic.yml workflow also ran on the jenkins-worker-rocm-amd-34 self-hosted runner. The logs confirmed that this workflow used a GITHUB_TOKEN with extensive write permissions.
@ericsciple could you please take this issue seriously and disable persisting credentials to disk?
Reacted by Marcel Richter, Tony Spataro, Jay Faulkner, Danny Slatkin, Yay295, Christian Nicolai, Bengt Brodersen and Sebastian Pipping
Activity
haampie commentedon Oct 5, 2021
I can't believe the default is to persist credentials and expose them to other jobs :( this is a major security issue.
Just as a heads up for anyone stumbling upon this issue:
persist-credentials: falseis only relevant when you use ssh authentication, becauseSo if you want to harden security, apart from setting
persist-credentials: falsefor ssh auth, make sure thatGITHUB_TOKENauth has no write permission to your repo.See https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/ for reference.
fmg-dave commentedon Oct 13, 2021
+1
eregon commentedon Jul 27, 2022
Agreed this seems a severe security issue, because it means any workflow using
actions/checkoutbasically leaks the token to any process/action in that workflow which can just read it from.git/config.@haampie IIUC it is a problem also with no ssh authentication (the default). The GitHub token is given only to this action and maybe a few other actions/* actions (
default: ${{ github.token }}only work for those AFAIK), but is otherwise given to no other action unless done explicitly (likewith: token: ${{ github.token }}/${{ secrets.GITHUB_TOKEN }}).The token is not in the environment.
In other words,
actions/checkoutleaks the token to.git/config, making it very easy to read for anything running inside the workflow.If the token was not written to
.git/config, then I think stealing the GitHub token would require (one of):So, depending on whether the token is explicitly passed to some action:
persist-credentials: false, regardless of the token permissions. A workaround is to set token permissionsI guess GitHub sees setting token permissions as the more general solution.
If so, fine, but then the default should be secure and so the default workflow permissions should be just
contents: read.https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ also has a mention related to this, search for
persist-credentials:mgoltzsche commentedon Jul 16, 2023
+1
ci: opt-out of checkout persist credentials.
ci: opt-out of checkout persist credentials.
ci: opt-out of checkout persist credentials.
[-]Release a new version v3 with `persist-credentials` removed or `false` by default[/-][+]Remove `persist-credentials` or change the default to `false`[/+]briansmith commentedon Sep 5, 2023
I updated the issue title since v3 and v4 have already shipped, so asking for a new v3 doesn't make sense.
ci: constrain GITHUB_TOKEN permissions
ci: don't persist Git credentials
haampie commentedon Jan 15, 2024
Fast forward to 2024, and we have https://johnstawinski.com/2024/01/11/playing-with-fire-how-we-executed-a-critical-supply-chain-attack-on-pytorch/
@ericsciple could you please take this issue seriously and disable persisting credentials to disk?
Don't persist credentials when not needed, and save verbose test results
ci: disable checkout.persist-credentials
ci: disable checkout.persist-credentials (#8882)
99 remaining items
Disable credential persistence in checkout action
Disable credential persistence in checkout action
Disable credential persistence in checkout action
Disable credential persistence in checkout action
Disable credential persistence in checkout action
Disable credential persistence in checkout action
Disable credential persistence in checkout action
Address https://docs.zizmor.sh/audits/#artipacked findings. (#3081)
.github: add explicit persist-credentials for checkout action (Victor…
nitrocode commentedon Oct 26, 2026
Perhaps, in the interim, a wrapper action would be better with the appropriate default set?
See https://github.com/infralicious/actions-checkout which acts as a pass-through composite action to actions/checkout
jobs: checkout: runs-on: ubuntu-latest steps: + - uses: infralicious/[email protected] - - uses: actions/[email protected] - with: - persist-credentials: falsersb-23 commentedon Oct 26, 2026
Its better to have a self owned wrapper rather than trusting a third-party.
If interested, fork this https://github.com/rsb-23/actions and use actions from your own account.
ci: add `persist-credentials: false` everywhere
ci: fix permissions on all workflows
ci: fix permissions on all workflows
ci: fix permissions on all workflows