MediumGHSA-j3f9-p6hm-5w6qCVE-2025-22145

Carbon has an arbitrary file include via unvalidated input passed to Carbon::setLocale

Published 8 Jan 2025 · Updated 25 Feb 2025

Affected packages

Affected
>=3.0.0 <3.8.4
Fixed in
3.8.4
Update to the fixed version for your release line, for example:composer require nesbot/carbon:^3.8.4
Affected
<2.72.6
Fixed in
2.72.6
Update to the fixed version for your release line, for example:composer require nesbot/carbon:^2.72.6

Details

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

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/File_inclusion_vulnerability

Credits

Thanks to Szczepan Hołyszewski who reported the issue and to Tidelift to coordinate the resolution

Is GHSA-j3f9-p6hm-5w6q in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected nesbot/carbon, and gives you the command that fixes it.

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.