Skip to content

Eliminate AWS credential exposure on fork PRs in REPL artefact workflow#6376

Merged
lukastaegert merged 8 commits into
masterfrom
resolve-aws-issue
May 16, 2026
Merged

Eliminate AWS credential exposure on fork PRs in REPL artefact workflow#6376
lukastaegert merged 8 commits into
masterfrom
resolve-aws-issue

Conversation

@lukastaegert

Copy link
Copy Markdown
Member

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

The existing repl-artefacts.yml workflow used pull_request_target with ref: ${{ github.event.pull_request.head.sha }}, which checks out and executes code from fork pull requests in a context that has access to repository secrets (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY). A maintainer adding the x⁸ ⚙️ build repl artefacts label to a malicious fork PR would trigger a build of that untrusted code with full access to the AWS credentials.

This is fixed by splitting the workflow into two parts:

repl-artefacts.yml — runs on pull_request (untrusted, no secrets):

  • Checks out fork code and runs the full build
  • Uploads the built artefacts as a GitHub Actions artifact
  • No secrets are available in this context

repl-artefacts-upload.yml — runs on workflow_run (trusted, never executes fork code):

  • Triggered when the build workflow completes successfully
  • Downloads the pre-built artifact from GitHub (which cannot be tampered with at this point)
  • Authenticates to AWS using OIDC (aws-actions/configure-aws-credentials) instead of long-lived static credentials — requires adding AWS_ROLE_ARN as a repository secret and configuring a corresponding IAM role that trusts token.actions.githubusercontent.com
  • Removes the x⁸ ⚙️ build repl artefacts label (moved here from the build workflow, since fork PRs on pull_request events have read-only GITHUB_TOKEN regardless of declared permissions)
  • Posts the PR comment as before

After merging, the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY secrets can be removed from the repository. See the AWS OIDC setup steps in the commit description.

Copilot AI review requested due to automatic review settings May 14, 2026 06:17
@vercel

vercel Bot commented May 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rollup Ready Ready Preview, Comment May 16, 2026 8:39am

Request Review

@lukastaegert lukastaegert changed the title security: eliminate AWS credential exposure on fork PRs in REPL artefact workflow Eliminate AWS credential exposure on fork PRs in REPL artefact workflow May 14, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Eliminates AWS credential exposure to fork PRs by splitting the REPL artefact pipeline into an untrusted build workflow (pull_request, no secrets) and a trusted upload workflow (workflow_run) that authenticates to AWS via OIDC and posts the PR comment.

Changes:

  • Convert repl-artefacts.yml from pull_request_target to pull_request; it now only builds and uploads a GitHub Actions artifact, with no AWS access.
  • Add repl-artefacts-upload.yml triggered via workflow_run, which downloads the artefact, removes the build label, authenticates to AWS via OIDC (AWS_ROLE_ARN), uploads to S3, and posts/updates the PR comment.
  • Move label removal and Vercel preview commenting into the trusted upload workflow.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
.github/workflows/repl-artefacts.yml Switched to untrusted pull_request build that only produces a GitHub Actions artifact; removed all AWS/secret usage and PR commenting.
.github/workflows/repl-artefacts-upload.yml New trusted workflow_run job that downloads the artefact, OIDC-auths to AWS, uploads to S3, removes label, and posts the PR comment.
Comments suppressed due to low confidence (2)

.github/workflows/repl-artefacts-upload.yml:102

  • patrickedqvist/wait-for-vercel-preview needs the PR head commit SHA to find the matching Vercel deployment. In a workflow_run-triggered job, github.sha does not reliably correspond to the PR head SHA, and no sha input is being passed here. As a result, the action may time out or never find the preview URL, and the comment with the Vercel preview link may stop being posted.

Consider explicitly forwarding the originating PR head SHA via the action's sha input, e.g. using ${{ github.event.workflow_run.head_sha }}.

      - name: Find Vercel preview URL
        uses: patrickedqvist/wait-for-vercel-preview@d7982701e6fcd3ae073bff929e408e004404d38d # v1.3.3
        id: waitForVercel
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/repl-artefacts-upload.yml:34

  • Deriving the PR number from the artifact directory name with ls | sed is fragile: if actions/download-artifact ever places additional files (e.g. a README, hidden file) or its naming convention changes, the captured PR_NUMBER will silently become incorrect — which could lead to commenting on the wrong PR and/or removing the label from the wrong PR.

A more robust approach is to have the build workflow write the PR number into the artifact itself (or upload it as a separate small artifact), and then read that file here, rather than parsing it from the directory name.

      - name: Get PR number
        id: pr-number
        run: |
          # The artifact is named repl-artefacts-pr-<number>
          PR_NUMBER=$(ls repl-artefacts | sed 's/repl-artefacts-pr-//')
          echo "pr-number=$PR_NUMBER" >> "$GITHUB_OUTPUT"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/repl-artefacts-upload.yml
@github-actions

github-actions Bot commented May 14, 2026

Copy link
Copy Markdown

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#resolve-aws-issue

Notice: Ensure you have installed the latest nightly Rust toolchain. If you haven't installed it yet, please see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust.

or load it into the REPL:
https://rollup-l0yhp57iz-rollup-js.vercel.app/repl/?pr=6376

@github-actions

github-actions Bot commented May 14, 2026

Copy link
Copy Markdown

Performance report

  • BUILD: 6890ms, 820 MB (-4%)
    • initialize: 0ms, 23.6 MB (+6%)
    • generate module graph: 2516ms, 633 MB
      • generate ast: 1329ms, 625 MB
    • sort and bind modules: 441ms, 691 MB (-2%)
    • mark included statements: 3898ms, 820 MB (-4%)
      • treeshaking pass 1: 2174ms, 823 MB (-2%)
      • treeshaking pass 2: 476ms, 835 MB (+3%)
      • treeshaking pass 3: 416ms, 818 MB (-4%)
      • treeshaking pass 4: 405ms, 816 MB
      • treeshaking pass 5: 402ms, 820 MB (-4%)
  • GENERATE: 708ms (-33ms, -4.5%), 912 MB
    • initialize render: 0ms, 820 MB (-4%)
    • generate chunks: 41ms, 844 MB (+4%)
      • optimize chunks: 0ms, 836 MB
    • render chunks: 647ms (-24ms, -3.6%), 894 MB
    • transform chunks: 19ms, 912 MB
    • generate bundle: 0ms, 912 MB

@codecov

codecov Bot commented May 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.78%. Comparing base (5cd8eef) to head (37cb7d7).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6376   +/-   ##
=======================================
  Coverage   98.78%   98.78%           
=======================================
  Files         274      274           
  Lines       10795    10795           
  Branches     2883     2883           
=======================================
  Hits        10664    10664           
  Misses         89       89           
  Partials       42       42           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This should reduce the attack surface and also avoid social engineering attacks.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

.github/workflows/repl-artefacts-upload.yml:38

  • Removing the label here runs on every successful build, including same-repo PRs that were never labeled (the build job triggers for any synchronize/opened event when head.repo.full_name == 'rollup/rollup'). gh pr edit --remove-label returns a non-zero exit code when the label is not present on the PR, which will fail the upload job and prevent the artefacts from ever being uploaded for ordinary internal PRs. Consider gating this step on the original event being a labeled action (e.g., by passing that info via the artifact) or by checking first whether the label is present.
      - name: Remove 'x⁸ ⚙️ build repl artefacts' label
        run: gh pr edit ${{ steps.pr-number.outputs.pr-number }} --remove-label 'x⁸ ⚙️ build repl artefacts'
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/repl-artefacts-upload.yml:102

  • patrickedqvist/wait-for-vercel-preview polls the GitHub deployments API for the SHA of the workflow event's checkout. Under workflow_run, the default GITHUB_REF/SHA is the default branch's HEAD, not the PR commit, so this action will not find the Vercel preview for the PR and the step will time out (or the if: steps.waitForVercel.outputs.url guard will silently skip the comment update). The SHA needs to be passed explicitly, e.g. via the action's sha input set to ${{ github.event.workflow_run.head_sha }}.
      - name: Find Vercel preview URL
        uses: patrickedqvist/wait-for-vercel-preview@d7982701e6fcd3ae073bff929e408e004404d38d # v1.3.3
        id: waitForVercel
        with:
          token: ${{ secrets.GITHUB_TOKEN }}

Comment thread .github/workflows/repl-artefacts-upload.yml Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/repl-artefacts-upload.yml Outdated
Comment thread .github/workflows/repl-artefacts-upload.yml

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread .github/workflows/repl-artefacts-upload.yml Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@lukastaegert lukastaegert merged commit 5f2bde9 into master May 16, 2026
109 of 111 checks passed
@lukastaegert lukastaegert deleted the resolve-aws-issue branch May 16, 2026 12:53
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown

This PR has been released as part of rollup@4.61.0. You can test it via npm install rollup.

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