{"answers":{"affected":"1 open source package ship an affected version, including https://github.com/pytorch/pytorch/.github/actions/filter-test-configs.","exploited":"There is no known exploitation of GHSA-hw6r-g8gj-2987 in the wild and no public exploit code.","fix":"No fix has been published for GHSA-hw6r-g8gj-2987 yet. Limit exposure of the affected software until one is available.","what":"GHSA-hw6r-g8gj-2987 is a code injection vulnerability in https://github.com/pytorch/pytorch/.github/actions/filter-test-configs, published on 30 Aug 2023. Any signed-in user can exploit it over the network, with no action from the victim."},"fix_prompt":"Check this codebase for GHSA-hw6r-g8gj-2987 and fix it if it is affected.\n\nWhat it is: GHSA-hw6r-g8gj-2987 is a code injection vulnerability in https://github.com/pytorch/pytorch/.github/actions/filter-test-configs, published on 30 Aug 2023. Any signed-in user can exploit it over the network, with no action from the victim.\nExploitation: There is no known exploitation of GHSA-hw6r-g8gj-2987 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- https://github.com/pytorch/pytorch/.github/actions/filter-test-configs (GitHub Actions): affected all versions; no fix listed\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-hw6r-g8gj-2987/ (Markdown: https://insights.sbomify.com/GHSA-hw6r-g8gj-2987/index.md)","id":"GHSA-hw6r-g8gj-2987","markdown":"https://insights.sbomify.com/GHSA-hw6r-g8gj-2987/index.md","name":"GHSA-hw6r-g8gj-2987","record":{"aliases":[],"analysis":{"component_type":"developer_tool","fix_type":"patch","impacts":["code_execution","data_read"],"network_reachable":"yes","non_default_config":true,"product_category":"GitHub Actions workflow","requires_auth":"low_privilege","summary":"Attackers can inject code via malicious branch names in PyTorch's filter-test-configs action, potentially leaking secrets and executing commands.","user_interaction":"not_required","vuln_class":"code_injection"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"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/)","ecosystems":["GitHub Actions"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":false,"headline":"Actions expression injection in `filter-test-configs` (`GHSL-2023-181`)","id":"GHSA-hw6r-g8gj-2987","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"GitHub Actions","product":null,"products":[],"type":"code_injection","year":"2023"},"n_packages":1,"n_references":null,"packages":[{"ecosystem":"GitHub Actions","fixed":[],"introduced":["0"],"last_affected":[],"package":"https://github.com/pytorch/pytorch/.github/actions/filter-test-configs","purl":null,"source":"GHSA-hw6r-g8gj-2987"}],"products":null,"published":"2023-08-30","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Attackers can inject code via malicious branch names in PyTorch's filter-test-configs action, potentially leaking secrets and executing commands.","url":"https://insights.sbomify.com/GHSA-hw6r-g8gj-2987/"}