Skip to content

Fix security vulnerability in workflows#1804

Merged
Juice10 merged 4 commits intomasterfrom
codex/pr-1803-review
Mar 17, 2026
Merged

Fix security vulnerability in workflows#1804
Juice10 merged 4 commits intomasterfrom
codex/pr-1803-review

Conversation

@Juice10
Copy link
Copy Markdown
Member

@Juice10 Juice10 commented Mar 17, 2026

Simplificaiton of #1803, fixes security issue introduced in #1787

Address a critical security vulnerability in the GitHub workflows by replacing the compressed-size-action with custom scripts to measure bundle sizes. This change enhances security by preventing arbitrary code execution through pull requests. Additionally, the workflows have been refactored for improved readability and maintainability. The necessary permissions for actions have been adjusted to ensure proper functionality.

eoghanmurray and others added 3 commits March 16, 2026 21:47
"The workflow .github/workflows/eslint-check.yml contained a critical "pwn request" vulnerability that allows any GitHub user to execute arbitrary code with access to repository secrets by opening a pull request."

See preactjs/compressed-size-action#54 for why that action shouldn't be used with pull_request_target

This change in this PR drops compressed-size-action in favour of executing the steps ourselves in two workflows, one which produces the size artifact, and the other which reads the artifact has the permissions to write the message back to the original PR (which is in a third party repo)
- Add `.github/scripts/measure-bundle-sizes.js` and
  `render-bundle-size-comment.js` to replace inline node scripts
  embedded in workflow YAML, improving readability and reusability
- Refactor `eslint-check.yml` to use the new script files and fix
  checkout steps to handle both PR and non-PR triggers correctly
- Refactor `pr-checks-privileged.yml` to replace the large
  `github-script` block with `render-bundle-size-comment.js` and
  the `marocchino/sticky-pull-request-comment` action; remove the
  now-unnecessary `pr_number.txt` artifact by reading the PR number
  directly from the workflow_run event
- Pin `ataylorme/eslint-annotate-action` to a specific commit SHA
- Add `actions: read` permission where needed for artifact downloads
Copilot AI review requested due to automatic review settings March 17, 2026 16:15
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 17, 2026

⚠️ No Changeset found

Latest commit: 69c76ad

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 17, 2026

Size Change: 0 B

Total Size: 10.1 MB

ℹ️ View Unchanged
Filename Size
packages/all/dist/all.cjs 578 kB
packages/all/dist/all.js 577 kB
packages/all/dist/all.umd.cjs 581 kB
packages/all/dist/all.umd.min.cjs 273 kB
packages/packer/dist/base-DF-ifV6c.cjs 18.3 kB
packages/packer/dist/base-DF-ifV6c.umd.cjs 19.4 kB
packages/packer/dist/base-DF-ifV6c.umd.min.cjs 10.1 kB
packages/packer/dist/base-Dgki_PiJ.js 18.2 kB
packages/packer/dist/pack.cjs 347 B
packages/packer/dist/pack.js 285 B
packages/packer/dist/pack.umd.cjs 2.25 kB
packages/packer/dist/pack.umd.min.cjs 1.73 kB
packages/packer/dist/packer.cjs 257 B
packages/packer/dist/packer.js 136 B
packages/packer/dist/packer.umd.cjs 1.28 kB
packages/packer/dist/packer.umd.min.cjs 1.25 kB
packages/packer/dist/unpack.cjs 769 B
packages/packer/dist/unpack.js 702 B
packages/packer/dist/unpack.umd.cjs 1.79 kB
packages/packer/dist/unpack.umd.min.cjs 1.57 kB
packages/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.cjs 37.6 kB
packages/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.js 37.5 kB
packages/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.umd.cjs 38.7 kB
packages/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.umd.min.cjs 22.9 kB
packages/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.cjs 34.3 kB
packages/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.js 34.2 kB
packages/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.umd.cjs 35.4 kB
packages/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.umd.min.cjs 21.2 kB
packages/plugins/rrweb-plugin-console-record/dist/rrweb-plugin-console-record.cjs 15 kB
packages/plugins/rrweb-plugin-console-record/dist/rrweb-plugin-console-record.js 14.9 kB
packages/plugins/rrweb-plugin-console-record/dist/rrweb-plugin-console-record.umd.cjs 16.1 kB
packages/plugins/rrweb-plugin-console-record/dist/rrweb-plugin-console-record.umd.min.cjs 8.03 kB
packages/plugins/rrweb-plugin-console-replay/dist/rrweb-plugin-console-replay.cjs 5.01 kB
packages/plugins/rrweb-plugin-console-replay/dist/rrweb-plugin-console-replay.js 4.9 kB
packages/plugins/rrweb-plugin-console-replay/dist/rrweb-plugin-console-replay.umd.cjs 6.07 kB
packages/plugins/rrweb-plugin-console-replay/dist/rrweb-plugin-console-replay.umd.min.cjs 3.27 kB
packages/plugins/rrweb-plugin-sequential-id-record/dist/rrweb-plugin-sequential-id-record.cjs 681 B
packages/plugins/rrweb-plugin-sequential-id-record/dist/rrweb-plugin-sequential-id-record.js 548 B
packages/plugins/rrweb-plugin-sequential-id-record/dist/rrweb-plugin-sequential-id-record.umd.cjs 1.76 kB
packages/plugins/rrweb-plugin-sequential-id-record/dist/rrweb-plugin-sequential-id-record.umd.min.cjs 1.47 kB
packages/plugins/rrweb-plugin-sequential-id-replay/dist/rrweb-plugin-sequential-id-replay.cjs 933 B
packages/plugins/rrweb-plugin-sequential-id-replay/dist/rrweb-plugin-sequential-id-replay.js 820 B
packages/plugins/rrweb-plugin-sequential-id-replay/dist/rrweb-plugin-sequential-id-replay.umd.cjs 2.01 kB
packages/plugins/rrweb-plugin-sequential-id-replay/dist/rrweb-plugin-sequential-id-replay.umd.min.cjs 1.61 kB
packages/record/dist/record.cjs 397 kB
packages/record/dist/record.js 397 kB
packages/record/dist/record.umd.cjs 400 kB
packages/record/dist/record.umd.min.cjs 184 kB
packages/replay/dist/replay.cjs 410 kB
packages/replay/dist/replay.js 410 kB
packages/replay/dist/replay.umd.cjs 414 kB
packages/replay/dist/replay.umd.min.cjs 196 kB
packages/replay/dist/style.css 2.45 kB
packages/replay/dist/style.min.css 1.97 kB
packages/rrdom-nodejs/dist/rrdom-nodejs.cjs 143 kB
packages/rrdom-nodejs/dist/rrdom-nodejs.js 142 kB
packages/rrdom-nodejs/dist/rrdom-nodejs.umd.cjs 145 kB
packages/rrdom-nodejs/dist/rrdom-nodejs.umd.min.cjs 68.2 kB
packages/rrdom/dist/rrdom.cjs 161 kB
packages/rrdom/dist/rrdom.js 160 kB
packages/rrdom/dist/rrdom.umd.cjs 163 kB
packages/rrdom/dist/rrdom.umd.min.cjs 75.3 kB
packages/rrweb-player/dist/events.js 159 kB
packages/rrweb-player/dist/global.css 240 B
packages/rrweb-player/dist/rrweb-player.cjs 294 kB
packages/rrweb-player/dist/rrweb-player.js 294 kB
packages/rrweb-player/dist/rrweb-player.umd.cjs 296 kB
packages/rrweb-player/dist/rrweb-player.umd.min.cjs 132 kB
packages/rrweb-player/dist/style.css 5.57 kB
packages/rrweb-player/dist/style.min.css 5 kB
packages/rrweb-snapshot/dist/rrweb-snapshot.cjs 176 kB
packages/rrweb-snapshot/dist/rrweb-snapshot.js 175 kB
packages/rrweb-snapshot/dist/rrweb-snapshot.umd.cjs 179 kB
packages/rrweb-snapshot/dist/rrweb-snapshot.umd.min.cjs 83.3 kB
packages/rrweb/dist/rrweb.cjs 560 kB
packages/rrweb/dist/rrweb.js 560 kB
packages/rrweb/dist/rrweb.umd.cjs 561 kB
packages/rrweb/dist/rrweb.umd.min.cjs 264 kB
packages/rrweb/dist/style.css 2.45 kB
packages/rrweb/dist/style.min.css 1.97 kB
packages/types/dist/types.cjs 5.63 kB
packages/types/dist/types.js 5.38 kB
packages/types/dist/types.umd.cjs 6.66 kB
packages/types/dist/types.umd.min.cjs 3.41 kB
packages/utils/dist/utils.cjs 6.25 kB
packages/utils/dist/utils.js 5.74 kB
packages/utils/dist/utils.umd.cjs 7.28 kB
packages/utils/dist/utils.umd.min.cjs 4.09 kB

compressed-size-action

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a two-stage PR CI flow where unprivileged pull_request runs produce lint + bundle-size artifacts, and a follow-up privileged workflow_run consumes those artifacts to post PR annotations/comments without checking out or executing fork code.

Changes:

  • Switch ESLint workflow trigger from pull_request_target to pull_request and upload lint/bundle-size artifacts.
  • Add base-branch build job to compute “base” bundle sizes for comparison.
  • Add privileged workflow_run workflow plus helper scripts to render and post bundle-size comments and ESLint annotations.

Reviewed changes

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

File Description
.github/workflows/pr-checks-privileged.yml New privileged workflow_run workflow to post PR comments/annotations from artifacts.
.github/workflows/eslint-check.yml Reworks ESLint CI to run on pull_request, upload artifacts, and build base branch for size comparison.
.github/scripts/render-bundle-size-comment.js Renders a markdown PR comment from PR/base size JSON inputs.
.github/scripts/measure-bundle-sizes.js Collects bundle file sizes under dist/ and writes them to JSON.

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

Comment thread .github/workflows/eslint-check.yml Outdated
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.head_ref }}
ref: ${{ github.head_ref }}
- name: Setup Node
uses: actions/setup-node@v3
ref: ${{ github.base_ref }}
}

const rootDir = process.cwd();
const sizes = {};
Comment on lines +114 to +122
const rows = files
.map((filePath) => {
const fileDiff = (prSizes[filePath] ?? 0) - (baseSizes[filePath] ?? 0);
return `| \`${getFileLabel(filePath, packageName)}\` | ${formatSize(
baseSizes[filePath],
)} | ${formatSize(prSizes[filePath])} | ${formatDiff(
fileDiff,
baseSizes[filePath] ?? 0,
)} |`;
- Look up PR number via API when workflow_run.pull_requests is empty
  (GitHub leaves it empty for fork PRs), falling back gracefully
- Use head SHA instead of branch name for PR checkout to avoid TOCTOU
- Fix formatSignedSize to produce +0 instead of -0 for zero values
- Gate comment steps on successful PR number lookup

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces a split GitHub Actions setup where unprivileged PR runs build/lint and upload artifacts, and a privileged workflow_run workflow consumes those artifacts to post PR comments and ESLint annotations without executing fork code.

Changes:

  • Switch eslint-check.yml from pull_request_target to pull_request, add bundle-size measurement + artifacts, and add a base-branch build job for bundle-size comparison.
  • Add a privileged workflow_run workflow to download artifacts and (a) post a sticky bundle-size PR comment and (b) publish ESLint annotations.
  • Add scripts to measure dist bundle sizes and render a markdown comment from PR vs base JSON size data.

Reviewed changes

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

File Description
.github/workflows/pr-checks-privileged.yml New privileged workflow_run workflow that downloads artifacts and posts PR comment + annotations.
.github/workflows/eslint-check.yml Runs on pull_request/push, uploads ESLint report artifact, measures PR bundle sizes, builds base branch for comparison, uploads combined size artifacts.
.github/scripts/render-bundle-size-comment.js Renders a markdown bundle size diff report grouped by package.
.github/scripts/measure-bundle-sizes.js Walks the workspace to collect dist/*.{js,cjs,mjs,css} file sizes into JSON.

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

const { data: prs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: `${run.head_repository.full_name}:${run.head_branch}`,

function walk(dirPath) {
for (const entry of fs.readdirSync(dirPath, { withFileTypes: true })) {
if (entry.name === 'node_modules') {
Comment on lines +69 to 75
- name: Checkout workflow ref
uses: actions/checkout@v4
- name: Prepare bundle size helper
run: |
cp .github/scripts/measure-bundle-sizes.js /tmp/measure-bundle-sizes.js
# --- Base branch ---
- uses: actions/checkout@v4
Copy link
Copy Markdown
Contributor

@eoghanmurray eoghanmurray left a comment

Choose a reason for hiding this comment

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

Happy to approve, pity it drops the emojis!

@Juice10
Copy link
Copy Markdown
Member Author

Juice10 commented Mar 17, 2026

Happy to approve, pity it drops the emojis!

Oh that is a shame indeed!

@Juice10 Juice10 merged commit acba854 into master Mar 17, 2026
18 checks passed
billyvg pushed a commit to getsentry/rrweb that referenced this pull request Mar 23, 2026
* Fix a security hole in rrweb-io#1787 found by Arun Murugesan:

"The workflow .github/workflows/eslint-check.yml contained a critical "pwn request" vulnerability that allows any GitHub user to execute arbitrary code with access to repository secrets by opening a pull request."

See preactjs/compressed-size-action#54 for why that action shouldn't be used with pull_request_target

This change in this PR drops compressed-size-action in favour of executing the steps ourselves in two workflows, one which produces the size artifact, and the other which reads the artifact has the permissions to write the message back to the original PR (which is in a third party repo)

* The annotate action also needed pull-requests: write permission (fixes failing run 'ESLint Annotation')

* ci(bundle-size): extract bundle size scripts and simplify workflow

- Add `.github/scripts/measure-bundle-sizes.js` and
  `render-bundle-size-comment.js` to replace inline node scripts
  embedded in workflow YAML, improving readability and reusability
- Refactor `eslint-check.yml` to use the new script files and fix
  checkout steps to handle both PR and non-PR triggers correctly
- Refactor `pr-checks-privileged.yml` to replace the large
  `github-script` block with `render-bundle-size-comment.js` and
  the `marocchino/sticky-pull-request-comment` action; remove the
  now-unnecessary `pr_number.txt` artifact by reading the PR number
  directly from the workflow_run event
- Pin `ataylorme/eslint-annotate-action` to a specific commit SHA
- Add `actions: read` permission where needed for artifact downloads

* ci: add fork PR support and harden workflow

- Look up PR number via API when workflow_run.pull_requests is empty
  (GitHub leaves it empty for fork PRs), falling back gracefully
- Use head SHA instead of branch name for PR checkout to avoid TOCTOU
- Fix formatSignedSize to produce +0 instead of -0 for zero values
- Gate comment steps on successful PR number lookup

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

---------

Co-authored-by: Eoghan Murray <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
billyvg pushed a commit to getsentry/rrweb that referenced this pull request Mar 23, 2026
* Fix a security hole in rrweb-io#1787 found by Arun Murugesan:

"The workflow .github/workflows/eslint-check.yml contained a critical "pwn request" vulnerability that allows any GitHub user to execute arbitrary code with access to repository secrets by opening a pull request."

See preactjs/compressed-size-action#54 for why that action shouldn't be used with pull_request_target

This change in this PR drops compressed-size-action in favour of executing the steps ourselves in two workflows, one which produces the size artifact, and the other which reads the artifact has the permissions to write the message back to the original PR (which is in a third party repo)

* The annotate action also needed pull-requests: write permission (fixes failing run 'ESLint Annotation')

* ci(bundle-size): extract bundle size scripts and simplify workflow

- Add `.github/scripts/measure-bundle-sizes.js` and
  `render-bundle-size-comment.js` to replace inline node scripts
  embedded in workflow YAML, improving readability and reusability
- Refactor `eslint-check.yml` to use the new script files and fix
  checkout steps to handle both PR and non-PR triggers correctly
- Refactor `pr-checks-privileged.yml` to replace the large
  `github-script` block with `render-bundle-size-comment.js` and
  the `marocchino/sticky-pull-request-comment` action; remove the
  now-unnecessary `pr_number.txt` artifact by reading the PR number
  directly from the workflow_run event
- Pin `ataylorme/eslint-annotate-action` to a specific commit SHA
- Add `actions: read` permission where needed for artifact downloads

* ci: add fork PR support and harden workflow

- Look up PR number via API when workflow_run.pull_requests is empty
  (GitHub leaves it empty for fork PRs), falling back gracefully
- Use head SHA instead of branch name for PR checkout to avoid TOCTOU
- Fix formatSignedSize to produce +0 instead of -0 for zero values
- Gate comment steps on successful PR number lookup

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

---------

Co-authored-by: Eoghan Murray <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
billyvg added a commit to getsentry/rrweb that referenced this pull request Mar 23, 2026
Cherry picks the following PRs that fix security vulns from GHA:

- rrweb-io#1787
- rrweb-io#1804

This also completely removes the privileged workflows added in
rrweb-io#1804 as they are not necessary
for us.

---------

Co-authored-by: Eoghan Murray <[email protected]>
Co-authored-by: Justin Halsall <[email protected]>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
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.

3 participants