Skip to content

ci: harden the bundle-snapshot workflow against fork PRs - #378

Open
atinux wants to merge 2 commits into
mainfrom
ci/bundle-snapshot-hardening
Open

ci: harden the bundle-snapshot workflow against fork PRs#378
atinux wants to merge 2 commits into
mainfrom
ci/bundle-snapshot-hardening

Conversation

@atinux

@atinux atinux commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

What

Splits the snapshot update into a tokenless build job (permissions: {}) that runs the PR's code and a privileged update job that only applies the resulting artifact, and makes the report job validate the artifact's pr-number/outcome and verify the PR head SHA against the workflow run before commenting; comment fences now adapt to backtick runs in PR-controlled text.

Why

A security scan found that fork PR code executed in a job holding a contents: write token (script-injection via $GITHUB_PATH/$GITHUB_ENV into the token-bearing github-script step), and that the fork-controlled artifact could drive bot comments on arbitrary issues or escape its own code fence. The update job no longer checks out or executes PR code at all.


🤖 Prepared by an AI agent (OpenCode) from a security-audit findings list; commits are signed by the repository owner's key.

atinux added 2 commits August 21, 2026 12:06
The update job checked out the fork PR head and ran pnpm
install/prepack/vitest in the same job as a contents:write
GITHUB_TOKEN — fork-controlled scripts could hijack the later
github-script step via GITHUB_PATH/GITHUB_ENV.

Split the work: a build job with permissions: {} runs the PR code and
uploads the refreshed snapshot as an artifact; the privileged update
job never checks out code and only applies the artifact (API commit for
branches, patch comment for forks).
The report job trusted the fork-controlled artifact's pr-number and
spliced its output.txt into a bot comment inside a fixed backtick
fence — a crafted payload could target arbitrary issues or break out of
the code block.

Validate the pr-number format and outcome values, verify the PR's head
SHA matches the workflow run, and fence the excerpt with a run longer
than any backtick run it contains.
@atinux
atinux requested a review from farnabaz as a code owner August 21, 2026 10:07
@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
comark Ready Ready Preview Aug 21, 2026 10:11am
comark-json-render Ready Ready Preview Aug 21, 2026 10:11am
comark-nextjs Ready Ready Preview Aug 21, 2026 10:11am
comark-nuxt Ready Ready Preview Aug 21, 2026 10:11am
comark-svelte Ready Ready Preview Aug 21, 2026 10:11am
comark-sveltekit Ready Ready Preview Aug 21, 2026 10:11am
comark-twoslash Ready Ready Preview Aug 21, 2026 10:11am
comark-vue Ready Ready Preview Aug 21, 2026 10:11am

@pkg-pr-new

pkg-pr-new Bot commented Aug 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

comark

npm i https://pkg.pr.new/comark@378

@comark/angular

npm i https://pkg.pr.new/@comark/angular@378

@comark/ansi

npm i https://pkg.pr.new/@comark/ansi@378

@comark/html

npm i https://pkg.pr.new/@comark/html@378

@comark/nuxt

npm i https://pkg.pr.new/@comark/nuxt@378

@comark/react

npm i https://pkg.pr.new/@comark/react@378

@comark/svelte

npm i https://pkg.pr.new/@comark/svelte@378

@comark/vue

npm i https://pkg.pr.new/@comark/vue@378

commit: 8a64b89

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.

1 participant