Open
Description
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
.
Metadata
Metadata
Assignees
Labels
No labels
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: false
is only relevant when you use ssh authentication, becauseSo if you want to harden security, apart from setting
persist-credentials: false
for ssh auth, make sure thatGITHUB_TOKEN
auth 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/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 (likewith: 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):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
:Github, rebase
action checkstyle/checkstyle#11134mgoltzsche 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.
actions/checkout
and disable persisted git credentials reactjs/react-rails#1307166 remaining items