# CVE-2023-52137: GitHub Action tj-actions/verify-changed-files is vulnerable to command injection in output filenames

> Attackers can execute arbitrary code and steal secrets via command injection in changed filenames within the verify-changed-files GitHub Action.

- **Severity:** High 7.7 (`CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:L/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 29 Dec 2023
- **Updated:** 2 Aug 2024
- **Also known as:** GHSA-ghm2-rq8q-wrhc

## What is CVE-2023-52137?

CVE-2023-52137 is a high-severity command injection vulnerability in tj-actions verify-changed-files, published on 29 Dec 2023. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

The [`tj-actions/verify-changed-files`](https://github.com/tj-actions/verify-changed-files) action allows for command injection in changed filenames, allowing an attacker to execute arbitrary code and potentially leak secrets. The [`verify-changed-files`](https://github.com/tj-actions/verify-changed-files) workflow returns the list of files changed within a workflow execution. This could potentially allow filenames that contain special characters such as `;` which can be used by an attacker to take over the [GitHub Runner](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners) if the output value is used in a raw fashion (thus being directly replaced before execution) inside a `run` block. By running custom commands, an attacker may be able to steal secrets such as `GITHUB_TOKEN` if triggered on other events than `pull_request`.

This has been patched in versions [17](https://github.com/tj-actions/verify-changed-files/releases/tag/v17) and [17.0.0](https://github.com/tj-actions/verify-changed-files/releases/tag/v17.0.0) by enabling `safe_output` by default and returning filename paths escaping special characters for bash environments.

Weakness: CWE-77 (Improper Neutralization of Special Elements used in a Command), CWE-20 (Improper Input Validation)

## Which versions are affected by CVE-2023-52137?

1 open source package ship an affected version, including tj-actions/verify-changed-files. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `tj-actions/verify-changed-files` | GitHub Actions | All versions | 17 |

Products: Tj-Actions Verify-Changed-Files.

## How do I fix CVE-2023-52137?

Upgrade tj-actions/verify-changed-files to 17 or later.

## Is CVE-2023-52137 being exploited?

There is no known exploitation of CVE-2023-52137 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-52137 and fix it if it is affected.

What it is: CVE-2023-52137 is a high-severity command injection vulnerability in tj-actions verify-changed-files, published on 29 Dec 2023. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-52137 in the wild and no public exploit code.

Affected packages and fixed versions:
- tj-actions/verify-changed-files (GitHub Actions): affected all versions; fixed in 17

Task:
1. 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.
2. 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.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2023-52137/ (Markdown: https://insights.sbomify.com/CVE-2023-52137/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-52137
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-52137
- OSV: https://osv.dev/vulnerability/CVE-2023-52137

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-52137/
Summaries are generated and may contain mistakes; the official description above is the record.
