Skip to content

Harden CI/CD workflows with pinned action versions and security#656

Draft
OskarDamkjaer wants to merge 1 commit intomainfrom
claude/review-github-actions-KNpir
Draft

Harden CI/CD workflows with pinned action versions and security#656
OskarDamkjaer wants to merge 1 commit intomainfrom
claude/review-github-actions-KNpir

Conversation

@OskarDamkjaer
Copy link
Collaborator

@OskarDamkjaer OskarDamkjaer commented Mar 5, 2026

All changes committed and pushed. Here's the motivation for each change:


Change Motivation & Sources

1. Pin all actions to full commit SHAs

Why: In March 2025, the tj-actions/changed-files action (used in 23,000+ repos) was compromised when attackers stole a PAT and rewrote mutable version tags to inject malicious code that dumped CI secrets to public logs. Mutable tags (@v4) can be silently rewritten at any time — pinning to a commit SHA makes this impossible.

Sources:

2. Add timeout-minutes: 30 to all jobs

Why: The default timeout is 360 minutes (6 hours). A stuck process — a hanging test, a deadlocked build, or a network issue — will silently consume your entire runner allocation. Explicit timeouts ensure fast failure and prevent billing surprises.

Sources:

3. Add explicit permissions to all workflows

Why: Without explicit permissions, GITHUB_TOKEN inherits the repository's default permissions (typically write for most scopes). This violates the principle of least privilege — if a workflow is compromised, the attacker gets broader access than necessary. Setting permissions: contents: read at the workflow level and elevating per-job narrows the blast radius.

Sources:

4. Standardize NODE_OPTIONS to --max_old_space_size=8192

Why: The value was inconsistent: setup-and-build used 4096, ci.yaml used 8192, deploy-demo.yml used 4096. This causes unpredictable OOM failures depending on which workflow runs and whether the build step's NODE_OPTIONS or the workflow-level one takes effect. Standardizing to 8192 across all workflows eliminates this inconsistency.

Sources:

5. Add concurrency groups to remaining workflows

Why: Without concurrency controls, multiple runs of the same workflow can execute simultaneously — wasting resources (benchmark, formatting check) or causing race conditions (publish workflows pushing versions concurrently). For publish workflows, cancel-in-progress: false ensures a running publish completes rather than being cancelled mid-release.

Added to: benchmark.yaml, pre-release-vscode-extension.yaml, publish-vscode-extension.yaml, formatting-integrity-check.yaml

Sources:

6. Check CI conclusion before npm publish

Why: publish-npm-packages.yaml triggers on workflow_run: completed, but completed fires regardless of whether CI passed or failed. Without if: github.event.workflow_run.conclusion == 'success', a failed CI run could still trigger a publish attempt. Added the condition to both the stable and canary release jobs.

Sources:

…rrency

- Pin all third-party actions to full commit SHAs to prevent supply chain attacks
- Add timeout-minutes: 30 to all jobs to prevent runaway runners
- Add explicit least-privilege permissions to all workflows missing them
- Standardize NODE_OPTIONS to --max_old_space_size=8192 across all workflows
- Add concurrency groups to benchmark, pre-release, publish-vscode, and formatting-integrity-check
- Only publish to npm when CI workflow succeeds (check workflow_run conclusion)
- Remove stale TODO comment in publish-vscode-extension.yaml

https://claude.ai/code/session_01RFj4gacppD2MFE6zEY9Lpe
@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

⚠️ No Changeset found

Latest commit: 987c5d5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

2 participants