# CVE-2025-22145: Carbon has an arbitrary file include via unvalidated input passed to Carbon::setLocale

> Attackers can achieve arbitrary code execution if applications pass unsanitized input to Carbon::setLocale and allow PHP file uploads.

- **Severity:** Medium 6.3 (`CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 8 Jan 2025
- **Updated:** 25 Feb 2025
- **Also known as:** CLSA-2025-1756946896, CLSA-2026-1771375695, DEBIAN-CVE-2025-22145, DLA-4068-1, GHSA-j3f9-p6hm-5w6q, UBUNTU-CVE-2025-22145

## What is CVE-2025-22145?

CVE-2025-22145 is a medium-severity vulnerability in CarbonPHP carbon, published on 8 Jan 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Carbon is an international PHP extension for DateTime. Application passing unsanitized user input to Carbon::setLocale are at risk of arbitrary file include, if the application allows users to upload files with .php extension in an folder that allows include or require to read it, then they are at risk of arbitrary code ran on their servers. This vulnerability is fixed in 3.8.4 and 2.72.6.

Weakness: CWE-98 (Improper Control of Filename for Include/Require Statement in PHP Program)

## Which versions are affected by CVE-2025-22145?

4 open source packages ship an affected version, including nesbot/carbon.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `nesbot/carbon` | Packagist | All versions | 2.72.6 |
| `nesbot/carbon` | Packagist | All versions | 2.72.6 |
| `nesbot/carbon` | Packagist | From 3.0.0 | 3.8.4 |
| `nesbot/carbon` | Packagist | From 3.0.0 | 3.8.4 |

## How do I fix CVE-2025-22145?

Upgrade nesbot/carbon to a fixed version for your release line: 2.72.6 or 3.8.4.

## Is CVE-2025-22145 being exploited?

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

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2025-22145 and fix it if it is affected.

What it is: CVE-2025-22145 is a medium-severity vulnerability in CarbonPHP carbon, published on 8 Jan 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2025-22145 in the wild and no public exploit code.

Affected packages and fixed versions:
- nesbot/carbon (Packagist): affected all versions; fixed in 2.72.6
- nesbot/carbon (Packagist): affected all versions; fixed in 2.72.6
- nesbot/carbon (Packagist): affected from 3.0.0; fixed in 3.8.4
- nesbot/carbon (Packagist): affected from 3.0.0; fixed in 3.8.4

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

## Sources

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

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