security: harden CI/CD pipeline against supply chain attacks#20
security: harden CI/CD pipeline against supply chain attacks#20ajag408 wants to merge 4 commits into
Conversation
|
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 (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughAdds CODEOWNERS for manifest files, adjusts npm/pnpm configs, and hardens CI/release workflows by adding runner hardening, disabling persisted checkout credentials, routing installs through a socket firewall via Corepack, making critical audit non-fatal, and adding a PR-only dependency-review job. ChangesSupply Chain Security Hardening
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/ci.yml:
- Around line 42-48: The Socket Firewall steps ("Set up Socket Firewall" action
socketdev/action) and the "Install dependencies" run step must explicitly expose
the API key by adding the secret as an environment variable (e.g., add an env
mapping SOCKET_SECURITY_API_KEY: ${{ secrets.SOCKET_SECURITY_API_KEY }} on the
Socket step and the run step that invokes `sfw pnpm install`) so the action and
`sfw` CLI can read it at runtime; replicate the same change for the security job
steps that run the firewall and `sfw` install. Ensure each step that invokes the
socket action or `sfw` commands has the env entry so the secret is available
during execution (and consider using workflow-level or job-level env if multiple
steps need it).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 97609dfa-cad3-4dfe-959f-c25b5110aee0
📒 Files selected for processing (2)
.github/workflows/ci.yml.github/workflows/release.yml
🚧 Files skipped from review as they are similar to previous changes (1)
- .github/workflows/release.yml
Motivation
The TanStack/Mini Shai-Hulud supply chain attack (May 2026) compromised 169 npm packages by poisoning GitHub Actions caches via PR CI runs, then publishing malicious packages through trusted release workflows.
Shield's
build-binariesjob shared a pnpm store cache between PR CI runs and release builds — the same vector TanStack was exploited through. Since Trust will consume the SEA binary directly, the entire build pipeline must be hardened before the next release tag.The monorepo already has most of these layers (Socket Firewall, harden-runner, persist-credentials). This PR brings Shield to parity and adds install-time controls the monorepo should also adopt.
Changes
Install-time hardening
enable-pre-post-scripts=true.npmrcpreinstall,preparehooks). Removing it blocks all lifecycle scripts by default.onlyBuiltDependencies: ["esbuild"]package.jsonesbuildneeds it (downloads platform binary). Everything else blocked.minimum-release-age=4320.npmrcRelease-path hardening
actions/cachefrombuild-binariesrelease.ymlpublishjob was already cache-free. ~30s slower, eliminates shared cache as attack vector.NPM_CONFIG_PROVENANCE=trueon publishrelease.ymlattest-build-provenancealready done for binaries. Consumers can verify the package was built by our GitHub Actions workflow.Detection
step-security/harden-runner(audit mode)ci.yml+release.ymlv2.16.1).persist-credentials: falseon all checkoutsci.yml+release.ymlGITHUB_TOKENfrom being persisted to.git/config. Matches monorepo.socketdev/action) on all installsci.yml+release.ymlSOCKET_SECURITY_API_KEYrepo secret (see below).actions/dependency-review-actionon PRsci.ymlpull_requestonly.Governance
.github/CODEOWNERS.npmrc,package.json,pnpm-lock.yamlto require review for supply-chain-critical files.What's NOT changed
Admin actions required
SOCKET_SECURITY_API_KEYas a repo secret (Settings → Secrets → Actions). Get the key from the monorepo's secrets or Socket dashboard.mainand tag protection onv*(see Slack thread / PR comments for details).Test plan
sfwvisible in logs)esbuildpostinstall still runs (build succeeds despiteonlyBuiltDependencies)build-binariesruns clean without cacheFollow-up (separate PRs / settings)
main(require PR review + CI, no force-push)v*release.ymltoegress-policy: blockSummary by CodeRabbit