Can pull requests change actions? #27084
-
One of the most common use cases for GitHub Actions is to run a test suite against pull requests. What happens if the pull request includes changed actions? I’m guessing the changed actions won’t run on the pull request itself (unlike actions changed in a push, which do run on the commit they are part of), otherwise that seems like a big security concern. Someone could use that to steal your secrets, for example. That said, I haven’t been able to find confirmation of this. Does anyone know for sure? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Pull requests can have their branch either in the source repo (yours) or a forked repo.
If you use actions owned by someone else and pass your secrets to them, then you need to make sure that they don’t misuse them. As such actions could be modified to be malicious at any time, you may want to review their code and specify the exact commit hash in your workflow instead of a branch or (partial) version tag:
Also see the documentation: You can also opt-in to only allow certain actions: Allowing specific actions to run I’m not sure whether local actions could pose a problem, in particular actions which you maintain in the same repo in combination with |
Beta Was this translation helpful? Give feedback.
-
Thank you for a very thorough response! |
Beta Was this translation helpful? Give feedback.
-
Just to make it clear if it wasn’t: Using
Keeping your GitHub Actions and workflows secure: Preventing pwn requestsIn this article, we’ll discuss some common security malpractices for GitHub Actions and workflows, and how to best avoid them. Our examples are based on real-world GitHub workflow implementation vulnerabilities the GitHub Security Lab has reported to... |
Beta Was this translation helpful? Give feedback.
Pull requests can have their branch either in the source repo (yours) or a forked repo.
Only users with write access to your repo can push to and create new branches in your repo, so it is assumed that they are trustworthy.
If the head branch is in a forked repo (external contributor), there is no access to secrets in the workflow. They will simply be not set. This applies to
on: pull_request
With
on: pull_request_target
as trigger, secrets can be accessed, but the workflow of the base branch is used (so the version trusted by you). Any changes done to.github/workflows/
by the PR are ignored, which should prevent malicious users from leaking secrets. Note that also the code of the …