Skip to content
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

Properly support previews in GitHub Actions #410

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

geofft
Copy link
Contributor

@geofft geofft commented Oct 28, 2024

We need access to the Cloudflare token to write the preview page, but we don't want this token to be available to code controlled by the pull request. Before this change the action used pull_request_target to get has write permissions, but as a consequence, it ran on the target branch so that it didn't run untrusted code from the pull request, so it didn't preview the right thing.

Instead, follow the approach outlined in
https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/ by splitting the work into two workflows in the pull request case. The first runs the build without access to secrets and stores the build result as a GHA artifact, and the second fetches the artifact and publishes the preview without running untrusted code.


This is untested and will probably need some tweaking once it lands to see if it's working right.

We need access to the Cloudflare token to write the preview page, but we
don't want this token to be available to code controlled by the pull
request. Before this change the action used `pull_request_target` to get
has write permissions, but as a consequence, it ran on the target branch
so that it didn't run untrusted code from the pull request, so it didn't
preview the right thing.

Instead, follow the approach outlined in
https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
by splitting the work into two workflows in the pull request case. The
first runs the build without access to secrets and stores the build
result as a GHA artifact, and the second fetches the artifact and
publishes the preview without running untrusted code.
@hsjobeki
Copy link
Collaborator

Thanks for the PR so far. I'll have a look over the christmas days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants