fix(security): PR Previews from Forks #110
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The Issue
Hey! I'm the maintainer of the Github Action refined-cf-pages-action and we were recently made aware of a security vulnerability regarding the
pull_request_target
workflow event where it's possible to leak secrets (including the CF credentials used in the action) through a Github Actions exploit when running untrusted code. Unfortunately, our previous recommendation for the setup of the PR Previews from Forks feature included the use of this workflow event type without PR approvals, which has now been updated.I'm going around to all of the dependents of the action that are using the PR Previews from Forks feature to apply the fix.
The Fix
We've come up with an alternate method that is safer to use and will resolve this issue entirely.
Rather than using
pull_request_target
, which runs in a privileged environment (meaning that repository secrets can be used in it), previews will now be deployed in two stages:build-preview.yml
) will use thepull_request
event, which runs in an unprivileged environment, making it safe to run untrusted code. The site will be built in this stage and the build directory will be uploaded to Github as an artifact.deploy-preview.yml
) will use theworkflow_run
event, which runs in a privileged environment where its only job will be to download the build artifact and then run therefined-cf-pages-action
action to upload the build files to Cloudflare Pages for preview deployment.And that's it! No further actions are necessary.
Thanks for your time!