GHSA-hw6r-g8gj-2987: //github.com/pytorch/pytorch/.github/actions/filter test configs Actions Expression Injection Vulnerability

MODERATE
Published
Advisory Summary

GHSA-hw6r-g8gj-2987 is a MODERATE actions expression injection vulnerability (General Security Weakness) affecting //github.com/pytorch/pytorch/.github/actions/filter test configs libraries in the GitHub Actions ecosystem. The issue involves actions expression injection in `filter-test-configs` (`ghsl-2023-181`). Remediation is available in the latest vendor maintenance releases.

GHSA-hw6r-g8gj-2987 at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-hw6r-g8gj-2987
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification General Security Weakness
Affected Product //github.com/pytorch/pytorch/.github/actions/filter test configs
Package Ecosystem GitHub Actions
Published Date
Last Updated

How to Fix GHSA-hw6r-g8gj-2987

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

https://github.com/pytorch/pytorch/.github/actions/filter-test-configs fixed: Latest secure release
<dependency>
    <groupId>https</groupId>
    <artifactId>//github.com/pytorch/pytorch/.github/actions/filter-test-configs</artifactId>
    <version>Latest secure release</version>
</dependency>
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 https://github.com/pytorch/pytorch/.github/actions/filter-test-configs

How to Check if You Are Affected

To determine whether your application is affected by GHSA-hw6r-g8gj-2987, inspect your project dependencies for //github.com/pytorch/pytorch/.github/actions/filter test configs:

inspect dependencies for https://github.com/pytorch/pytorch/.github/actions/filter-test-configs

Analyze the terminal output to locate any version of //github.com/pytorch/pytorch/.github/actions/filter test configs in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than the patched release), 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 General Security Weakness. In //github.com/pytorch/pytorch/.github/actions/filter test configs, 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

The `pytorch/pytorch` `filter-test-configs` workflow is vulnerable to an expression injection in Actions, allowing an attacker to potentially leak secrets and alter the repository using the workflow. ### Details The [`filter-test-configs`](https://github.com/pytorch/pytorch/blob/ec26947c586dd323d741da80008403664c533f65/.github/actions/filter-test-configs/action.yml) workflow is using the raw `github.event.workflow_run.head_branch` value inside the `filter` step: ```yaml - name: Select all requested test configurations shell: bash env: GITHUB_TOKEN: ${{ inputs.github-token }} JOB_NAME: ${{ steps.get-job-name.outputs.job-name }} id: filter run: | ... python3 "${GITHUB_ACTION_PATH}/../../scripts/filter_test_configs.py" \ ... --branch "${{ github.event.workflow_run.head_branch }}" ``` In the event of a repository using `filter-test-configs` in a `pull_request_target`-triggered workflow, an attacker could use a malicious branch name to gain command execution in the step and potentially leak secrets. ```yml name: Example on: pull_request_target jobs: example: runs-on: ubuntu-latest steps: - name: Filter uses: pytorch/pytorch/.github/actions/filter-test-configs@v2 ``` #### Impact This issue may lead to stealing workflow secrets. #### Remediation 1. Use an intermediate environment variable for potentially attacker-controlled values such as `github.event.workflow_run.head_branch`: ```yaml - name: Select all requested test configurations shell: bash env: GITHUB_TOKEN: ${{ inputs.github-token }} JOB_NAME: ${{ steps.get-job-name.outputs.job-name }} HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }} id: filter run: | ... python3 "${GITHUB_ACTION_PATH}/../../scripts/filter_test_configs.py" \ ... --branch "$HEAD_BRANCH" ``` #### Resources * [CodeQL for JavaScript - Expression injection in Actions](https://codeql.github.com/codeql-query-help/javascript/js-actions-command-injection/) * [Keeping your GitHub Actions and workflows secure Part 2: Untrusted input](https://securitylab.github.com/research/github-actions-untrusted-input/) * [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)

GHSA-hw6r-g8gj-2987 Affected //github.com/pytorch/pytorch/.github/actions/filter test configs Versions

1 component(s)
Product / Package Ecosystem Affected Versions Fixed Version
https://github.com/pytorch/pytorch/.github/actions/filter-test-configs
GitHub Actions

References

Frequently Asked Questions

What is GHSA-hw6r-g8gj-2987?
GHSA-hw6r-g8gj-2987 is a security vulnerability in //github.com/pytorch/pytorch/.github/actions/filter test configs involving Actions expression injection in `filter-test-configs` (`GHSL-2023-181`) under General Security Weakness.
Which //github.com/pytorch/pytorch/.github/actions/filter test configs versions are affected?
Affected versions include releases prior to current release patches across affected packages: https://github.com/pytorch/pytorch/.github/actions/filter-test-configs.
What version fixes GHSA-hw6r-g8gj-2987?
Upgrading to current release patches (or the latest patched release for your respective branch) resolves the vulnerability.
Is //github.com/pytorch/pytorch/.github/actions/filter-test-configs affected?
Yes, https://github.com/pytorch/pytorch/.github/actions/filter-test-configs is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
What CWE is associated with GHSA-hw6r-g8gj-2987?
GHSA-hw6r-g8gj-2987 is classified under General Security Weakness.
How can I check GitHub Actions dependencies for GHSA-hw6r-g8gj-2987?
Run the dependency tree command: 'inspect dependencies for https://github.com/pytorch/pytorch/.github/actions/filter-test-configs'. 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-hw6r-g8gj-2987",
  "modified" : "2023-08-30T20:47:13Z",
  "published" : "2023-08-30T20:47:13Z",
  "aliases" : [ ],
  "summary" : "Actions expression injection in `filter-test-configs` (`GHSL-2023-181`)",
  "details" : "The `pytorch/pytorch` `filter-test-configs` workflow is vulnerable to an expression injection in Actions, allowing an attacker to potentially leak secrets and alter the repository using the workflow.\n\n### Details\n\nThe [`filter-test-configs`](https://github.com/pytorch/pytorch/blob/ec26947c586dd323d741da80008403664c533f65/.github/actions/filter-test-configs/action.yml) workflow is using the raw `github.event.workflow_run.head_branch` value inside the `filter` step:\n\n```yaml\n- name: Select all requested test configurations\n  shell: bash\n  env:\n    GITHUB_TOKEN: ${{ inputs.github-token }}\n    JOB_NAME: ${{ steps.get-job-name.outputs.job-name }}\n  id: filter\n  run: |\n    ...\n    python3 \"${GITHUB_ACTION_PATH}/../../scripts/filter_test_configs.py\" \\\n      ...\n      --branch \"${{ github.event.workflow_run.head_branch }}\"\n```\n\nIn the event of a repository using `filter-test-configs` in a `pull_request_target`-triggered workflow, an attacker could use a malicious branch name to gain command execution in the step and potentially leak secrets.\n\n```yml\nname: Example\n\non: pull_request_target\n\njobs:\n  example:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Filter\n        uses: pytorch/pytorch/.github/actions/filter-test-configs@v2\n```\n\n#### Impact\n\nThis issue may lead to stealing workflow secrets.\n\n#### Remediation\n\n1. Use an intermediate environment variable for potentially attacker-controlled values such as `github.event.workflow_run.head_branch`:\n```yaml\n- name: Select all requested test configurations\n  shell: bash\n  env:\n    GITHUB_TOKEN: ${{ inputs.github-token }}\n    JOB_NAME: ${{ steps.get-job-name.outputs.job-name }}\n    HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}\n  id: filter\n  run: |\n    ...\n    python3 \"${GITHUB_ACTION_PATH}/../../scripts/filter_test_configs.py\" \\\n      ...\n      --branch \"$HEAD_BRANCH\"\n```\n\n#### Resources\n\n* [CodeQL for JavaScript - Expression injection in Actions](https://codeql.github.com/codeql-query-help/javascript/js-actions-command-injection/)\n* [Keeping your GitHub Actions and workflows secure Part 2: Untrusted input](https://securitylab.github.com/research/github-actions-untrusted-input/)\n* [Keeping your GitHub Actions and workflows secure Part 1: Preventing pwn requests](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)\n",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "GitHub Actions",
      "name" : "https://github.com/pytorch/pytorch/.github/actions/filter-test-configs"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "< 2.0.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pytorch/pytorch/security/advisories/GHSA-hw6r-g8gj-2987"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pytorch/pytorch"
  } ],
  "database_specific" : {
    "cwe_ids" : [ ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-08-30T20:47:13Z",
    "nvd_published_at" : null
  }
}