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

Published Jan 8, 2025
·
Updated

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

5 affected componentsFixes available
composer/nesbot/carbon<2.72.6
2.72.6
composer/nesbot/carbon>=3.0.0<3.8.4
3.8.4
composer/nesbot/carbon<2.72.6
2.72.6
composer/nesbot/carbon>=3.0.0, <3.8.4
3.8.4
ubuntu/php-nesbot-carbon<1.27.0-2ubuntu0.1~esm1
1.27.0-2ubuntu0.1~esm1

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade composer/nesbot/carbon to a version that resolves this vulnerability.

    Fixed in 2.72.6
  2. Upgrade

    Upgrade composer/nesbot/carbon to a version that resolves this vulnerability.

    Fixed in 3.8.4
  3. Upgrade

    Upgrade ubuntu/php-nesbot-carbon to a version that resolves this vulnerability.

    Fixed in 1.27.0-2ubuntu0.1~esm1
  4. Upgrade

    Upgrade briannesbitt/Carbon to a version that resolves this vulnerability.

    Fixed in 3.8.4
  5. Upgrade

    Upgrade briannesbitt/Carbon to a version that resolves this vulnerability.

    Fixed in 2.72.6
  6. Compensating control

    Call Carbon::setLocale() only with a whitelisted supported locale, and validate input before the call by forbidding or removing '/' and '\'.

  7. Compensating control

    Store uploaded files outside the application base directory, using a remote storage service or a local service run by another user.

  8. Compensating control

    When uploading files, rename them so they cannot have a .php extension.

Event History

Jan 8, 2025
CVE Published
via MITRE·08:40 PM
Data Sourced
via MITRE·08:40 PM
DescriptionWeakness
Advisory Published
via GitHub·09:03 PM
Data Sourced
via GitHub·09:03 PM
DescriptionWeaknessAffected Software
Data Sourced
via Packagist·09:03 PM
DescriptionSeverityAffected Software
Data Sourced
via OSV·09:15 PM
DescriptionSeverityAffected Software
Data Sourced
via NVD·09:15 PM
DescriptionSeverityWeakness
Dec 2, 2026
Updated
via OSV·02:19 AM
Affected Software

Frequently Asked Questions

1

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.

2

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.

3

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.

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.

5

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.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203