# CVE-2023-23946: Git's `git apply` overwriting paths outside the working tree

> Attackers can overwrite files outside the working tree by crafting malicious input to git apply, potentially modifying user data.

- **Severity:** Medium 6.2 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 14 Feb 2023
- **Updated:** 8 Oct 2026
- **Also known as:** ALPINE-CVE-2023-23946, CLEANSTART-2026-ZB48297, CLSA-2024-1714728645, DEBIAN-CVE-2023-23946, GHSA-r87m-v37r-cwfh, UBUNTU-CVE-2023-23946

## What is CVE-2023-23946?

CVE-2023-23946 is a medium-severity path traversal vulnerability in git, published on 14 Feb 2023. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

Git, a revision control system, is vulnerable to path traversal prior to versions 2.39.2, 2.38.4, 2.37.6, 2.36.5, 2.35.7, 2.34.7, 2.33.7, 2.32.6, 2.31.7, and 2.30.8. By feeding a crafted input to `git apply`, a path outside the working tree can be overwritten as the user who is running `git apply`. A fix has been prepared and will appear in v2.39.2, v2.38.4, v2.37.6, v2.36.5, v2.35.7, v2.34.7, v2.33.7, v2.32.6, v2.31.7, and v2.30.8. As a workaround, use `git apply --stat` to inspect a patch before applying; avoid applying one that creates a symbolic link and then creates a file beyond the symbolic link.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

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

It affects 1 product.


Products: Git-Scm Git.

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

Upgrade to a fixed version.

## Is CVE-2023-23946 being exploited?

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

Public exploit code:

- Explanation and POC of the CVE-2023-23946 (github_poc): https://github.com/bruno-1337/CVE-2023-23946-POC
- Original standalone Proof-of-Concept exploit for CVE-2023-23946 (Git path traversal via crafted patches in git-apply). (github_poc): https://github.com/tralsesec/CVE-2023-23946

## Other vulnerabilities in git

- [CVE-2022-23521](https://insights.sbomify.com/CVE-2022-23521/): gitattributes parsing integer overflow in git (critical 9.8)
- [CVE-2022-41903](https://insights.sbomify.com/CVE-2022-41903/): Integer overflow in `git archive`, `git log --format` leading to RCE in git (critical 9.8)
- [CVE-2019-1353](https://insights.sbomify.com/CVE-2019-1353/): Security feature bypass in Git (critical 9.8)
- [CVE-2016-2315](https://insights.sbomify.com/CVE-2016-2315/): Memory corruption in n/a (critical 9.8)
- [CVE-2016-2324](https://insights.sbomify.com/CVE-2016-2324/): Integer overflow in n/a (critical 9.8)

## Fix prompt for AI coding agents

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

What it is: CVE-2023-23946 is a medium-severity path traversal vulnerability in git, published on 14 Feb 2023. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-23946 in the wild and no public exploit code.

Affected product: git. No package-level version data is available, so check the vendor advisory linked from the reference page.

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-23946/ (Markdown: https://insights.sbomify.com/CVE-2023-23946/index.md)
```

## Sources

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

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