Improve Actions security #157949
Replies: 3 comments 1 reply
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
|
Also, maybe there should be a way for a Footnotes
|
Beta Was this translation helpful? Give feedback.
-
|
@Marcono1234 thanks for the feedback here, we are definitely digging into these areas of how to make Actions more secure by default.
I wanted to share that we are making progress in this area by restricting the executed workflows to the default branch for /cc @Steve-Glass |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Select Topic Area
Product Feedback
Body
Foreword
This is intended as feedback / suggestions for the GitHub Actions team, but anyone else feel free to share your thoughts on this as well.
There are multiple aspects of GitHub Actions which make their usage insecure or risky. The sections below try to mention some of them, explaining the issues with them and proposing potential solutions. There are definitely more risks which are not covered here. The issues here are not new, they have been publicly discussed in the past already, for example by GitHub's Security Lab.
If you notice anything which I describe incorrectly below, please let me know. Also, the proposed solutions below are based on my naive perspective on this, maybe there are limitations which prevent implementing these solutions, or there are better or more effective solutions.
pull_request_targetstale branchesFor
pull_request_targeta big problem is that it runs based on the target branch of the PR (the Security Lab post Keeping your GitHub Actions and workflows secure Part 4 mentions that as "Lurking Threats in Non-Default Branches").This is quite problematic because:
pull_request_targetis claimed to be fixed, might still be vulnerable on non-default branchespull_request_targetworkflows is difficult and time consumingpull_request_targetworkflows requires coordination with all project members to avoid someone pushing a feature branch with the vulnerable workflow in the meantime againpull_request_targetworkflows might go unnoticed by security researchers and tooling, if the default branch is not vulnerablepull_request_targetworkflow and a malicious user creates a PR against it(maybe the risk is lower because the owner of the fork needs to enable Actions there, which users sometimes do to test things though; and workflows might not run there for first-time contributors?)
Proposed solutions
pull_request_targetwithoutbranchesfilter only runs for the default branchbranchesfilter is specified and a PR is created against a non-default branch, the workflow fails (!= skipped) with an informative message (mentioning also the security aspect / linking to the GitHub Docs), so that maintainers can adjust the workflow in case they want to support non-default branchesbranchesfilter can be used to enable additional branchesImpostor commits
When the
uses:clause of a workflow pins an action to a commit SHA (e.g.uses: actions/checkout@<commit-sha>), then this commit might not actually be part of the referenced repository, but instead be only in a (potentially malicious) fork of it. This is called impostor commit.So when a malicious user creates a PR claiming to update
actions/checkout@<commit-sha>in your repository, they might actually point it to a malicious commit in their fork. Many users are probably not aware of this quirk of GitHub, and might fall for it. This can be made even more convincing if the malicious user uses tools to generate a commit with specific SHA so that it looks very similar to a commit from the real repository.Proposed solutions
There seems to be no valid use case where this behavior provides any advantage, and its only effect is that it deceives users.
Cache poisoning
When a workflow runs for a branch within a repository (e.g. the case for
pull_request_target) and is processing data from a malicious user, it might allow them to write to the cache of the repository, which then poisons other workflow runs which restore the cache.This can happen even if the vulnerable workflow itself does not perform any caching, an expression injection vulnerability might already suffice to exploit this, see also AdnaneKhan/Cacheract#16.
Proposed solutions
pushevents, all other events should only have at most read permissionsCaching is intended to speed up subsequent builds. However, except for
pushevents the underlying source code did not change so there should normally not be any need to update the cache. And in the worst case the next build is a bit slower, but the advantage of eliminating large attack surfaces for cache poisoning should probably be more important here.Maybe cache write permissions would also make sense for
pull_request, but then it would have to make sure that this cannot be exploited by a user who forks the repository of a victim, poisons the cache of their fork and then creates a PR from the victim repository to their fork (or similar), poisoning the repository of the victim. In that case the cache should be per PR (in case it isn't already).Beta Was this translation helpful? Give feedback.
All reactions