Repository navigation
fix(ci): don't checkout PR head in pull_request_target - #1311
Conversation
pull_request_target runs with write access to secrets. Checking out the untrusted PR head SHA in this context is a known SSRF/code-exec risk (CodeQL alert #1): a malicious fork PR could place code that later steps inadvertently execute while the PAT is in scope. The backport action uses the GitHub API to cherry-pick commits by SHA — it does not need the PR branch checked out as HEAD. Removing the ref: parameter makes checkout use the base branch (trusted code) instead. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
|
This change is part of the following stack: Change managed by git-spice. |
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe backport workflow's checkout action is updated to authenticate using a personal access token stored in ChangesBackport Authentication
🎯 2 (Simple) | ⏱️ ~10 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Summary
ref: ${{ github.event.pull_request.head.sha }}from theactions/checkoutstep in the backport workflowpull_request_targetruns with write access to secrets (needed to create backport PRs); checking out the unreviewed fork head in this context is a CodeQL high-severity finding (alert cmd/ncps: Implement urfave/cli and the serve command #1): a malicious fork PR could place code that gets executed while the PAT is in scopekorthout/backport-actionresolves commit SHAs via the GitHub API — it does not require the PR branch to be the current HEAD; removingref:makes the checkout use the base branch (trusted, reviewed code) insteadTest plan
backportlabel and verify the backport action still creates the backport PR correctly