Skip to content

fix: mitigate shell injection in discussion workflow (MSRC 110700)#360

Open
nicholasdbrady wants to merge 1 commit intomainfrom
fix/msrc-110700-shell-injection
Open

fix: mitigate shell injection in discussion workflow (MSRC 110700)#360
nicholasdbrady wants to merge 1 commit intomainfrom
fix/msrc-110700-shell-injection

Conversation

@nicholasdbrady
Copy link
Copy Markdown
Member

Summary

Fixes a critical shell injection vulnerability in .github/workflows/on-discussion-created.yml (MSRC Case 110700).

Vulnerability

The "Dispatch to foundry-docs" step interpolated user-controlled ${{ github.event.discussion.* }} expressions directly into a bash run: block. Since GitHub Actions expands ${{ }} before the shell runs, an attacker could create a discussion with a crafted title to break out of single quotes and execute arbitrary commands on the runner — potentially exfiltrating the FOUNDRY_DOCS_DISPATCH_TOKEN secret.

Attack vector: Any user can create a discussion on this public repository (no permissions required).

Fix

  • Moved all user-controlled expressions to env: variables — values are set as environment variables and are NOT subject to shell interpretation
  • JSON payload built with jq using --arg/--argjson — proper escaping of all special characters (quotes, backticks, $, etc.)
  • curl -fsS — fail loudly on HTTP errors instead of silent failure

Testing

The fix has been validated through code review and rubber-duck analysis. The jq tool is pre-installed on GitHub-hosted ubuntu-latest runners.

Move user-controlled GitHub Actions expressions (${{ github.event.discussion.* }})
from inline shell interpolation to env: variables to prevent shell injection.
Use jq for safe JSON payload construction instead of string concatenation.

Previously, discussion title/number/url were interpolated directly into a
bash run: block via ${{ }} expansion. An attacker could craft a discussion
title to break out of single quotes and execute arbitrary commands,
potentially exfiltrating the FOUNDRY_DOCS_DISPATCH_TOKEN secret.

Fix details:
- All user-controlled expressions moved to env: block (safe from shell interpretation)
- JSON payload built with jq --arg/--argjson (proper escaping of all special chars)
- curl uses -fsS flags to fail loudly on HTTP errors

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

1 participant