Skip to content

fix: stop running fork PR code in tag-validation workflow - #333

Merged
allison-truhlar merged 1 commit into
mainfrom
fix-tag-validation-checkout
Sep 14, 2026
Merged

allison-truhlar merged 1 commit into
mainfrom
fix-tag-validation-checkout

Conversation

@allison-truhlar

@allison-truhlar allison-truhlar commented Sep 14, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Tag validation fails on fork PRs (e.g. #331):

Refusing to check out fork pull request code from a 'pull_request_target' workflow.

The workflow used pull_request_target and checked out refs/pull/N/merge, then ran npm ci and validate-tags.js from that tree. That means a fork could modify the validator or its dependencies and run arbitrary code with the base repo's GITHUB_TOKEN. actions/checkout@v4 now blocks this by default.

Fix

  • Check out the base branch, so scripts and package.json always come from trusted code.
  • Fetch pull/N/merge and git checkout FETCH_HEAD -- only the changed *.md/*.mdx files (same ignore list as before).
  • Drop tj-actions/changed-files; the changed-file list now comes from git diff on the fetched merge ref.

Deleted files are excluded (--diff-filter=AM) so nothing tries to check out a missing path.

Testing

Ran the new diff/filter pipeline locally against pull/331/merge; it produced the expected list of 35 changed project files and excluded the .github/ changes. Ran validate-tags.js under Node 20 on a sample of those files; no validation report produced.

Because pull_request_target runs the workflow file from main, this must merge before #331 will pass.

@krokicki

actions/checkout@v4 now refuses to check out fork PR code from a
pull_request_target workflow, which broke validation on every external
PR. Rather than opting into the unsafe checkout, check out the base
branch so the validator and its npm dependencies always come from
trusted code, then fetch the PR merge ref and copy in only the changed
markdown files.

This also replaces tj-actions/changed-files with a git diff, since the
file list is now computed from the fetched merge ref.
@github-actions

Copy link
Copy Markdown

🎉 Thank you for your contribution!

The website maintainers will review your PR soon.

@allison-truhlar
allison-truhlar merged commit e7dc16b into main Sep 14, 2026
1 check passed
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