The vulnerability is a classic command injection in a GitHub Action. The root cause is in the action.yml file, where user-provided inputs.args were directly substituted into a shell command. The shell then interpreted these arguments, executing any embedded commands.
The analysis of the patch 016cabf33a6b7edf0733e179a03ad408ad4e88ba clearly shows the vulnerable code and the fix. The vulnerable part was the run step of the Run SonarScanner job in action.yml. It took the inputs.args and performed shell expansion on them: args=(${{ inputs.args }}). This is dangerous because it allows an attacker to inject commands.
The fix involves two main changes:
- In
action.yml, the arguments are no longer directly placed into the run block. Instead, they are passed as an environment variable INPUT_ARGS to a new wrapper script, run-sonar-scanner.sh.
- The script that ultimately processes the arguments,
run-sonar-scanner-cli.sh, was heavily modified. It no longer accepts arguments directly from the command line ($@). Instead, it reads the INPUT_ARGS environment variable and uses a regular expression with egrep to safely parse the arguments, correctly handling quotes and preventing the shell from executing injected commands.
Therefore, the function run-sonar-scanner-cli.sh is identified as the vulnerable function. While the injection point was in action.yml, this script is the component that would appear in a runtime profile as it's the one processing the malicious input passed by the action's runner.