CodeIgniter4 upload checks can miss a hidden PHP extension

2026-12-03来源 dev.toEnglish

CodeIgniter4 upload checks can miss a hidden PHP extension

CVE-2026-142155 affects CodeIgniter4 before version 4.7.5. The is_image and mime_in rules accept filenames whose trailing dots hide a PHP extension. The same validation rules and ext_in also accept a PHP extension placed before the final image extension. A file that looks acceptable to validation can therefore remain executable when an application preserves the client filename and stores it in a web-accessible directory that runs PHP.

The library behavior creates a dangerous composition, but the application still supplies the final conditions. The advisory identifies three that matter: validation relies on is_image or mime_in without an independent extension check, the client filename is preserved, and uploads land in a script-enabled public path. A deployment that stores random names outside the document root may be affected by the validation flaw but not expose the execution path in the same way.

Upgrade to CodeIgniter4 4.7.5 or later. Then inspect upload code rather than relying on framework version alone. Look for $file->move() calls that keep getName() or another client-controlled name. Prefer getRandomName() and a storage location outside the public web root. If files must be public, disable script execution in that directory and serve content through a handler that sets a fixed content type.

A recovery review should include more than changed files. Search upload directories for double extensions, trailing dots, unusual PHP signatures and files whose modification time does not match a deployment. Check web-server access logs for requests to uploaded paths, then compare those paths with application upload records. The presence of a suspicious filename is a lead; execution evidence establishes a different level of concern.

Teams should also test their validation rules with adversarial names such as an image name containing a PHP extension before the final suffix and names ending in dots or spaces. The goal is not to reproduce an exploit against production, but to prove that validation and storage use the same canonical filename. A safe test can assert that the stored extension is allowed and that the random storage name discards the client suffix entirely.

The broader lesson is that file type checks are not a storage policy. MIME detection, extension checks, random filenames, directory permissions and execution controls protect different layers. A modern framework patch should be paired with a deployment test that proves those layers agree.

References

原文:https://www.a8q9.cn/en/article/codeigniter4-upload-checks-can-miss-a-hidden-php-extension-5c3f3b.html

相关文章