CVE-2025-22145: Nesbot/carbon :setLocale Vulnerability
MODERATECVE-2025-22145 is a MODERATE :setlocale vulnerability (CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion')) affecting Nesbot/carbon libraries in the Packagist ecosystem. The issue involves :setlocale. Remediation is available by upgrading affected packages to version 3.8.4, 2.72.6.
CVE-2025-22145 at a Glance
How to Fix CVE-2025-22145
To remediate this vulnerability, upgrade all affected Nesbot/carbon dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade nesbot/carbon to 3.8.4
Upgrade nesbot/carbon to 2.72.6
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for nesbot/carbon
How to Check if You Are Affected
To determine whether your application is affected by CVE-2025-22145, inspect your project dependencies for Nesbot/carbon:
inspect dependencies for nesbot/carbon
Analyze the terminal output to locate any version of Nesbot/carbon in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.8.4), 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 CWE-98: Improper Control of Filename for Include/Require Statement in PHP Program ('PHP Remote File Inclusion'), where the php application receives input from an upstream component, but it does not restrict or incorrectly restricts the input before its usage in "require," "include," or similar functions. In Nesbot/carbon, 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
CVE-2025-22145 Affected Nesbot/carbon Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nesbot/carbon
|
Packagist |
≥ 3.0.0
< 3.8.4
|
3.8.4
|
|
nesbot/carbon
|
Packagist |
< 2.72.6
|
2.72.6
|
References
Frequently Asked Questions
What is CVE-2025-22145?
Which Nesbot/carbon versions are affected?
What version fixes CVE-2025-22145?
Is nesbot/carbon affected?
What CWE is associated with CVE-2025-22145?
How can I check Packagist dependencies for CVE-2025-22145?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-j3f9-p6hm-5w6q",
"modified" : "2025-02-25T18:39:47Z",
"published" : "2025-01-08T21:03:28Z",
"aliases" : [ "CVE-2025-22145" ],
"summary" : "Carbon has an arbitrary file include via unvalidated input passed to Carbon::setLocale",
"details" : "### Impact\nApplication 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.\n\n### Patches\n- [3.8.4](https://github.com/briannesbitt/Carbon/releases/tag/3.8.4)\n- [2.72.6](https://github.com/briannesbitt/Carbon/releases/tag/2.72.6)\n\n### Workarounds\nAny of the below actions can be taken to prevent the issue:\n- Validate input before calling `setLocale()`, for instance by forbidding or removing `/` and `\\`\n- Call `setLocale()` only with a locale from a whitelist of supported locales\n- When uploading files, rename them so they cannot have a `.php` extension (this is recommended even if you're not affected by this issue)\n- Prefer storage system that are not local to the application (remote service, or local service ran by another user so the uploaded files actually live outside of the application basedir)\n\n### References\nhttps://en.wikipedia.org/wiki/File_inclusion_vulnerability\n\n### Credits\nThanks to **Szczepan Hołyszewski** who reported the issue and to Tidelift to coordinate the resolution",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Packagist",
"name" : "nesbot/carbon"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.0.0"
}, {
"fixed" : "3.8.4"
} ]
} ]
}, {
"package" : {
"ecosystem" : "Packagist",
"name" : "nesbot/carbon"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.72.6"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/CarbonPHP/carbon/security/advisories/GHSA-j3f9-p6hm-5w6q"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-22145"
}, {
"type" : "WEB",
"url" : "https://github.com/briannesbitt/Carbon/commit/129700ed449b1f02d70272d2ac802357c8c30c58"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/CarbonPHP/carbon"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2025/02/msg00032.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-98" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-01-08T21:03:28Z",
"nvd_published_at" : "2025-01-08T21:15:13Z"
}
}