Skip to content

fix: pin 2 actions to commit SHA, extract 2 expressions to env vars#7541

Open
dagecko wants to merge 2 commits intomermaid-js:developfrom
dagecko:runner-guard/fix-ci-security
Open

fix: pin 2 actions to commit SHA, extract 2 expressions to env vars#7541
dagecko wants to merge 2 commits intomermaid-js:developfrom
dagecko:runner-guard/fix-ci-security

Conversation

@dagecko
Copy link
Copy Markdown

@dagecko dagecko commented Mar 27, 2026

Re-submission of #7529. Had a problem with my fork and had to delete it, which closed the original PR. Apologies for the noise.

Summary

This PR pins all GitHub Actions to immutable commit SHAs instead of mutable version tags and extracts expressions from run: blocks into env: mappings.

  • Pin 2 unpinned actions to full 40-character SHAs
  • Add version comments for readability
  • Extract 2 expressions from run blocks to env vars

Changes by file

File Changes
release-preview-publish.yml Pinned actions to SHA
unlock-reopened-issues.yml Pinned actions to SHA
validate-lockfile.yml Pinned actions to SHA

A note on internal action pinning

This PR pins all actions including org-owned ones. Best practice is to pin everything — the tj-actions/changed-files attack was an internally maintained action that was compromised, and every repo referencing it by tag silently executed attacker code. That said, it's your codebase. If you'd prefer to leave org-owned actions unpinned, let us know and we'll adjust the PR.

How to verify

Review the diff — each change is mechanical and preserves workflow behavior:

  • SHA pinning: action@v3 becomes action@abc123 # v3 — original version preserved as comment
  • Expression extraction: ${{ expr }} in run: moves to env: block, referenced as $ENV_VAR in the script
  • No workflow logic, triggers, or permissions are modified

I put up some research on this on Twitter and a research site if you want more context. I wrote a scanner called Runner Guard and open sourced it here.

If you have any questions, reach out. I'll be monitoring comms.

- Chris Nyhuis (dagecko)

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 27, 2026

⚠️ No Changeset found

Latest commit: 7e389ab

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

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 27, 2026

Deploy Preview for mermaid-js ready!

Name Link
🔨 Latest commit 7e389ab
🔍 Latest deploy log https://app.netlify.com/projects/mermaid-js/deploys/69c811ae8f65c6000877f036
😎 Deploy Preview https://deploy-preview-7541--mermaid-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment on lines +9 to +13
runs-on: ubuntu-latest
steps:
- uses: Dunning-Kruger/unlock-issues@b06b7f7e5c3f2eaa1c6d5d89f40930e4d6d9699e # v1
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 27, 2026

Open in StackBlitz

@mermaid-js/examples

npm i https://pkg.pr.new/@mermaid-js/examples@7541

mermaid

npm i https://pkg.pr.new/mermaid@7541

@mermaid-js/layout-elk

npm i https://pkg.pr.new/@mermaid-js/layout-elk@7541

@mermaid-js/layout-tidy-tree

npm i https://pkg.pr.new/@mermaid-js/layout-tidy-tree@7541

@mermaid-js/mermaid-zenuml

npm i https://pkg.pr.new/@mermaid-js/mermaid-zenuml@7541

@mermaid-js/parser

npm i https://pkg.pr.new/@mermaid-js/parser@7541

@mermaid-js/tiny

npm i https://pkg.pr.new/@mermaid-js/tiny@7541

commit: 7e389ab

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.34%. Comparing base (e9d4c11) to head (7e389ab).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           develop   #7541   +/-   ##
=======================================
  Coverage     3.34%   3.34%           
=======================================
  Files          524     524           
  Lines        55256   55256           
  Branches       795     795           
=======================================
  Hits          1850    1850           
  Misses       53406   53406           
Flag Coverage Δ
unit 3.34% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Did some research into the CodeQL envvar-injection-critical guidance
(https://codeql.github.com/codeql-query-help/actions/actions-envvar-injection-critical/)
and wanted to add this additional change to prevent shell injection
through attacker-controllable values like ref names and workflow inputs,
and to prevent unexpected behavior from special characters in secret values.

Before: echo ${REF_NAME}
After:  echo "${REF_NAME}"
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