Skip to content

Harden CI workflow - #39

Merged
lwr20 merged 8 commits into
projectcalico:mainfrom
lwr20:fix/pwn-request-ci-workflow
Mar 25, 2026
Merged

lwr20 merged 8 commits into
projectcalico:mainfrom
lwr20:fix/pwn-request-ci-workflow

Conversation

@lwr20

@lwr20 lwr20 commented Mar 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Hardens the CI workflow:

  • Replace pull_request_target with pull_request so fork PRs no longer run with access to FOSSA_API_KEY, QUAY_TOKEN, or a write-capable GITHUB_TOKEN
  • Remove the safe to test label gate on the test job (no longer needed — fork PR code runs without secrets by design)
  • Gate the FOSSA scan step to push events only, preventing auth failures on fork PRs where FOSSA_API_KEY is unavailable

The deploy job is unaffected — it was already gated to push events only.

Ref: https://www.stepsecurity.io/blog/hackerbot-claw-github-actions-exploitation

🤖 Generated with Claude Code

@lwr20 lwr20 changed the title Fix pwn request vulnerability in CI workflow Harden CI workflow Mar 25, 2026
@lwr20
lwr20 requested review from Behnam-Shobiri and Copilot March 25, 2026 10:26

Copilot AI left a comment

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.

Pull request overview

Hardens the CI workflow to prevent forked PRs from running with repository secrets and elevated GITHUB_TOKEN permissions, while keeping deploy restricted to push events.

Changes:

  • Switch workflow trigger from pull_request_target to pull_request and remove the safe to test label gate.
  • Pin GitHub Actions to commit SHAs and set explicit job permissions.
  • Run FOSSA scan only on push events to avoid missing-secret failures on fork PRs.

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

Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/ci.yml Outdated
Comment thread .github/workflows/ci.yml Outdated
lwr20 and others added 6 commits March 25, 2026 11:03
Replace pull_request_target with pull_request to prevent fork PRs from
running with access to FOSSA_API_KEY, QUAY_TOKEN, and GITHUB_TOKEN.
Remove the safe-to-test label gate (no longer needed) and gate the FOSSA
scan to push events only so it doesn't fail on fork PRs with missing secrets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Explicitly set permissions to contents:read and checks:write (the
latter for golangci-lint PR annotations) rather than relying on the
org default write-all token.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces mutable version tags (v4, v5, etc.) with pinned commit SHAs
to prevent supply chain attacks via tag force-push, as demonstrated
by the hackerbot-claw attack against Trivy. Also fixes the deploy job
if condition to use bare expression syntax rather than mixing template
and expression syntax.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The deploy job pushes images to Quay using QUAY_TOKEN, not the
GITHUB_TOKEN, so packages:write on the GITHUB_TOKEN is not needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Gate e2e test to push and same-repo PRs only; fork PRs skip it to
  avoid burning CI resources on untrusted code
- Remove redundant job-level if condition (workflow only triggers on
  push and pull_request)
- Simplify deploy checkout ref to github.sha (deploy only runs on push)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Consistent with the deploy job; the pull_request_target workaround of
explicitly specifying the PR head SHA is no longer needed now that we
use the pull_request trigger.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lwr20
lwr20 force-pushed the fix/pwn-request-ci-workflow branch from d3b58d6 to 94b5a25 Compare March 25, 2026 11:03
Forks don't have FOSSA_API_KEY configured, so the scan was failing on
pushes to fork branches. Adding a repo check prevents it running anywhere
other than the upstream projectcalico/tiger-bench repo.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread .github/workflows/ci.yml
Comment thread .github/workflows/ci.yml

@Behnam-Shobiri Behnam-Shobiri left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just 2 nits
Thank you for fixing this

Prevents GITHUB_TOKEN credentials being stored in the local git config
after checkout, reducing the risk of accidental credential exposure in
subsequent steps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lwr20
lwr20 merged commit d094158 into projectcalico:main Mar 25, 2026
8 checks passed
@lwr20
lwr20 deleted the fix/pwn-request-ci-workflow branch March 25, 2026 14:48
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