-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: address security risks in GitHub Actions workflows #1651
base: master
Are you sure you want to change the base?
Conversation
|
Thanks for sharing this @AdnaneKhan and putting in the time to find this exploit, and find the recent PR. We have been using |
That’s your decision - so the root cause (that allows an exploit) here is the workflow that runs code on pull_request_target from fork PRs combined with the release workflow consuming the cache. Ideally, you should look at overhauling the CI so that you use the pull_request trigger (not pull_request_target) to run the untrusted code, then use a second workflow on workflow_run to upload the results/format code, etc. This pattern is called out in https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/. Thats a more involved change, though. The changes in this PR protect your release secrets from immediate risk. Even if someone did try a cache poisoning attack they would not be able to cause real harm (such as stealing the NPM secret - which we can agree would lead to a big miss if rrweb was backdoored). I can work on contributing a follow-up PR to design a more robust release process for the project once this one is implemented. Better to remove the immediate risk first, though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all these suggested changes, I went through them to try to understand and double check everything. Looks really good, I thought it would make sense to go as strict as we can since we're looking at it right now so I suggested some stricter permissions
The recent pull request mentions I don't understand what dangers there might be with cache: yarn but I guess we'll find out!.
It turns out, this adds a lot of danger. An attacker can compromise the NPM token and the Chrome extension release secrets fairly easily by leveraging a technique known as GitHub Actions cache poisoning.
This happens because the
style-check.yml
workflow runs onpull_request_target
. I've updated the workflows to do a few things:GITHUB_TOKEN
permissions in other workflows that consume the cacheIdeally, you should move away from running user-controlled code from forks on
pull_request_target
, but that requires a more substantial overhaul to the repository's CI. The changes here will make it impossible to directly compromise the release secrets.Some background on cache poisoning: