Skip to content

ci: bot workflow TOCTOU and execution hardening [PM-22117]#848

Merged
m2ux merged 12 commits into
mainfrom
fix/PM-22117-bot-workflow-security-hardening
Mar 13, 2026
Merged

ci: bot workflow TOCTOU and execution hardening [PM-22117]#848
m2ux merged 12 commits into
mainfrom
fix/PM-22117-bot-workflow-security-hardening

Conversation

@m2ux

@m2ux m2ux commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Harden four comment-triggered bot workflows against TOCTOU race conditions and expression injection vulnerabilities identified by CI/CD security audit (M-F001, M-F002, M-F003, M-F004).

🎫 PM-22117 📐 Engineering 🧪 Test Plan


Motivation

Bot workflows (rebuild-metadata-bot, rebuild-chainspec-bot, cargo-fmt-bot, fix-metadata-conflicts-bot) check out PR code by branch name instead of commit SHA, creating a TOCTOU window where unreviewed commits can be injected between the permission check and code execution. In the two earthly-based bots, this code runs with repository secret access via .envrc sourcing and Docker privileged mode. Additionally, several workflows interpolate user-supplied inputs (pr_number, strategy) directly into JavaScript execution contexts, enabling expression injection.


Changes

  • rebuild-metadata-bot.yml — SHA-based checkout, removed .envrc sourcing (set EARTHLY_CONFIG explicitly), fixed pr_number expression injection via env: block
  • rebuild-chainspec-bot.yml — SHA-based checkout, removed .envrc sourcing (set EARTHLY_CONFIG explicitly), fixed pr_number expression injection via env: block
  • cargo-fmt-bot.yml — SHA-based checkout, fixed pr_number expression injection via env: block
  • fix-metadata-conflicts-bot.yml — SHA-based checkout, fixed pr_number and strategy expression injection via env: blocks

📌 Submission Checklist

  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason: CI workflow-only changes, no runtime impact
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • No new todos introduced

🔱 Fork Strategy

  • Node Runtime Update
  • Node Client Update
  • Other
  • N/A

🗹 TODO before merging

  • Ready for review

@github-actions

github-actions Bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

kics-logo

KICS version: v2.1.19

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 2
MEDIUM MEDIUM 52
LOW LOW 3
INFO INFO 64
TRACE TRACE 0
TOTAL TOTAL 121
Metric Values
Files scanned placeholder 27
Files parsed placeholder 27
Files failed to scan placeholder 0
Total executed queries placeholder 73
Queries failed to execute placeholder 0
Execution time placeholder 11

@m2ux m2ux force-pushed the fix/PM-22117-bot-workflow-security-hardening branch from 6646de2 to c6e0b2f Compare March 3, 2026 10:35
m2ux added 5 commits March 3, 2026 10:40
…-22117]

- Checkout by commit SHA instead of branch name to close TOCTOU window
- Remove .envrc sourcing; set EARTHLY_CONFIG explicitly via env: block
- Move pr_number from direct interpolation to env: block with process.env

Made-with: Cursor
…M-22117]

- Checkout by commit SHA instead of branch name to close TOCTOU window
- Remove .envrc sourcing; set EARTHLY_CONFIG explicitly via env: block
- Move pr_number from direct interpolation to env: block with process.env

Made-with: Cursor
- Checkout by commit SHA instead of branch name to close TOCTOU window
- Move pr_number from direct interpolation to env: block with process.env

Made-with: Cursor
…on [PM-22117]

- Checkout by commit SHA instead of branch name to close TOCTOU window
- Move pr_number from direct interpolation to env: block with process.env
- Move strategy from direct interpolation to env: block with process.env

Made-with: Cursor
…into fix/PM-22117-bot-workflow-security-hardening
@m2ux m2ux marked this pull request as ready for review March 3, 2026 12:03
@m2ux m2ux requested a review from a team as a code owner March 3, 2026 12:03
@m2ux m2ux self-assigned this Mar 3, 2026
m2ux added 2 commits March 4, 2026 11:44
…flow-security-hardening

Made-with: Cursor

# Conflicts:
#	.github/workflows/rebuild-metadata-bot.yml
@m2ux

m2ux commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

/bot rebuild-metadata

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

✅ Metadata rebuild complete. No changes detected.

@m2ux

m2ux commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

/bot rebuild-chainspec qanet

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

❌ Chainspec rebuild failed. Check the workflow logs for details.

@m2ux

m2ux commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

/bot rebuild-chainspec devnet

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

✅ Chainspec rebuild complete! Changes have been committed.

@m2ux

m2ux commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

/bot cargo-fmt

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

✅ Cargo format complete. No changes detected.

@m2ux

m2ux commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

/bot fix-metadata-conflicts

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

❌ Failed to fix metadata conflicts. Check the workflow logs for details.

@m2ux

m2ux commented Mar 4, 2026

Copy link
Copy Markdown
Contributor Author

/bot fix-metadata-conflicts accept-current

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

ℹ️ No conflicts detected between this PR and the main branch.

@ozgb ozgb 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.

Looks good! chainspec changes need reverting before merge

Comment thread res/devnet/chain-spec-raw.json
@m2ux m2ux enabled auto-merge March 5, 2026 09:04
@m2ux m2ux changed the title fix(ci): bot workflow TOCTOU and execution hardening [PM-22117] ci: bot workflow TOCTOU and execution hardening [PM-22117] Mar 6, 2026
@m2ux m2ux requested review from gilescope and ozgb March 6, 2026 09:27
Signed-off-by: Giles Cope <gilescope@gmail.com>
@m2ux m2ux added this pull request to the merge queue Mar 13, 2026
Merged via the queue into main with commit 2b1a13c Mar 13, 2026
34 checks passed
@m2ux m2ux deleted the fix/PM-22117-bot-workflow-security-hardening branch March 13, 2026 14:47
gilescope pushed a commit that referenced this pull request Apr 8, 2026
@gilescope gilescope added this to the node-1.0.0 milestone Apr 10, 2026
m2ux added a commit that referenced this pull request Apr 23, 2026
This reverts commit 15cbc58.
Signed-off-by: Mike Clay <mike.clay@shielded.io>
m2ux added a commit that referenced this pull request Apr 23, 2026
This reverts commit 15cbc58.
Signed-off-by: Mike Clay <mike.clay@shielded.io>
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.

4 participants