Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/e2e-brev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ jobs:
BRANCH=$(gh pr view ${{ inputs.pr_number }} --repo ${{ github.repository }} --json headRefName -q .headRefName)
echo "Resolved PR #${{ inputs.pr_number }} → branch: $BRANCH"
echo "RESOLVED_BRANCH=$BRANCH" >> "$GITHUB_ENV"
# Use the PR head ref for checkout — works for both fork and non-fork PRs.
echo "PR_REF=refs/pull/${{ inputs.pr_number }}/head" >> "$GITHUB_ENV"

- name: Checkout target branch
uses: actions/checkout@v6
with:
ref: ${{ env.RESOLVED_BRANCH || inputs.branch || 'main' }}
ref: ${{ env.PR_REF || inputs.branch || 'main' }}
Comment on lines +118 to +124
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.

⚠️ Potential issue | 🔴 Critical

Block untrusted fork PR refs before secret-backed checkout.

Line 119 and Line 124 now enable running fork PR code (refs/pull/<N>/head) in a job that later exposes BREV_API_TOKEN and NVIDIA_API_KEY. That is a secret-exfiltration path unless you gate fork PRs by trust level (or explicit maintainer opt-in).

🔒 Suggested guard before setting PR_REF
       - name: Resolve branch from PR number
         if: inputs.pr_number != ''
         env:
           GH_TOKEN: ${{ github.token }}
         run: |
           BRANCH=$(gh pr view ${{ inputs.pr_number }} --repo ${{ github.repository }} --json headRefName -q .headRefName)
+          IS_FORK=$(gh pr view ${{ inputs.pr_number }} --repo ${{ github.repository }} --json isCrossRepository -q .isCrossRepository)
+          AUTHOR_ASSOC=$(gh pr view ${{ inputs.pr_number }} --repo ${{ github.repository }} --json authorAssociation -q .authorAssociation)
+          if [ "$IS_FORK" = "true" ] && ! echo "$AUTHOR_ASSOC" | grep -Eq '^(OWNER|MEMBER|COLLABORATOR)$'; then
+            echo "::error::Refusing to run secret-backed e2e for untrusted fork PR #${{ inputs.pr_number }} (authorAssociation=$AUTHOR_ASSOC)."
+            exit 1
+          fi
           echo "Resolved PR #${{ inputs.pr_number }} → branch: $BRANCH"
           echo "RESOLVED_BRANCH=$BRANCH" >> "$GITHUB_ENV"
           # Use the PR head ref for checkout — works for both fork and non-fork PRs.
           echo "PR_REF=refs/pull/${{ inputs.pr_number }}/head" >> "$GITHUB_ENV"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/e2e-brev.yaml around lines 118 - 124, The workflow is
currently unconditionally setting PR_REF to refs/pull/${{ inputs.pr_number
}}/head and then checking it out (actions/checkout@v6), which allows fork PRs to
run code in jobs that have secrets (BREV_API_TOKEN, NVIDIA_API_KEY); change the
logic that sets or uses PR_REF so fork PR refs are only used for
trusted/internal PRs or explicit maintainer opt-in: detect whether the PR head
repo matches the repository owner (e.g., compare
github.event.pull_request.head.repo.full_name or head.repo.owner.login to
github.repository or github.repository_owner) and only set PR_REF / perform the
checkout of refs/pull/... when that check passes (otherwise fall back to
inputs.branch or 'main'), or gate the checkout behind an explicit input like
inputs.trust_pr_from_fork that must be true and approved by a maintainer before
exposing secrets. Ensure the checkout step (actions/checkout@v6) uses the
guarded PR_REF value so secrets are never exposed to untrusted fork refs.


- name: Create check run (pending)
if: inputs.pr_number != ''
Expand Down
Loading