CVE-2025-22145: Carbon has an arbitrary file include via unvalidated input passed to Carbon::setLocale
Impact 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.
Patches - 3.8.4 - 2.72.6
Workarounds Any of the below actions can be taken to prevent the issue: - Validate input before calling setLocale(), for instance by forbidding or removing / and \ - Call setLocale() only with a locale from a whitelist of supported locales - When uploading files, rename them so they cannot have a .php extension (this is recommended even if you're not affected by this issue) - 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)
References https://en.wikipedia.org/wiki/Fileinclusionvulnerability
Credits Thanks to Szczepan Hołyszewski who reported the issue and to Tidelift to coordinate the resolution
Other sources
Carbon has an arbitrary file include via unvalidated input passed to Carbon::setLocale
— Packagist
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.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
composer/nesbot/carbonto a version that resolves this vulnerability.Fixed in 2.72.6 - Upgrade
Upgrade
composer/nesbot/carbonto a version that resolves this vulnerability.Fixed in 3.8.4 - Upgrade
Upgrade
ubuntu/php-nesbot-carbonto a version that resolves this vulnerability.Fixed in 1.27.0-2ubuntu0.1~esm1 - Upgrade
Upgrade
briannesbitt/Carbonto a version that resolves this vulnerability.Fixed in 3.8.4 - Upgrade
Upgrade
briannesbitt/Carbonto a version that resolves this vulnerability.Fixed in 2.72.6 - Compensating control
Call Carbon::setLocale() only with a whitelisted supported locale, and validate input before the call by forbidding or removing '/' and '\'.
- Compensating control
Store uploaded files outside the application base directory, using a remote storage service or a local service run by another user.
- Compensating control
When uploading files, rename them so they cannot have a .php extension.
Event History
Frequently Asked Questions
What is the severity of CVE-2025-22145?
CVE-2025-22145 has been classified as a high severity vulnerability due to the potential for arbitrary file inclusion.
How do I fix CVE-2025-22145?
To fix CVE-2025-22145, ensure you sanitize all user inputs passed to Carbon::setLocale and restrict file uploads by disabling the upload of PHP files.
Which versions of nesbot/carbon are affected by CVE-2025-22145?
CVE-2025-22145 affects nesbot/carbon versions prior to 2.72.6 and those within the range of 3.0.0 to 3.8.4.
What potential risks does CVE-2025-22145 pose?
CVE-2025-22145 may allow attackers to execute arbitrary code on the server through file upload vulnerabilities if not mitigated properly.
Is there a patch available for CVE-2025-22145?
Yes, the patch for CVE-2025-22145 can be found in the updated versions of nesbot/carbon, specifically 2.72.6 and 3.8.4.