
PHP getimagesize() CVE-2025-14177 - Heap Memory Leak Exploit Generator Fully functional exploit chain in Python
getimagesize() Heap Memory LeakFor authorized penetration testing and security research only.
| Field | Value |
|---|---|
| CVE | CVE-2025-14177 |
| CWE | CWE-524 (Use of Uninitialized Resource) |
| Severity | MODERATE — CVSS 6.3 |
| Root cause | php_read_stream_all_chunks() writes successive chunks to buffer[0], overwriting previous data with uninitialized heap memory |
getimagesize("php://filter/.../resource=malicious.jpg", $info)
└─ php_read_stream_all_chunks()
├─ Chunk 1 (8KB) → memcpy(buffer+0, chunk1, 8192)
├─ Chunk 2 (8KB) → memcpy(buffer+0, chunk2, 8192) ← overwrites!
└─ $info['APP1'] = chunk2 + uninitialized heap garbage
Malicious JPEG carries an oversized APP1 marker (16KB) to force the multi-chunk read path. The returned APP1 field leaks heap memory that may contain credentials, tokens, session data, or ASLR pointers.
[1] RECON Find PHP app exposing getimagesize() output (APP1 field)
[2] PREP Craft malicious.jpg (APP1 = 16KB)
[3] EXPLOIT Upload → trigger getimagesize($file, $info)
[4] EXTRACT Parse $info['APP1'] for leaked heap data
[5] IMPACT Credential theft / token extraction / ASLR bypass
python3 CVE-2025-14177.py [mode]
./exploit_output/)exploit_output/
├── malicious.jpg # crafted JPEG payload (APP1 = 16KB)
├── exploit_standalone.php # deployable PHP exploit
├── exploit_report.json # full analysis report
└── test_cases.json # 3 test scenarios
| Case | Vector |
|---|---|
| 1 | Direct upload → getimagesize($_FILES[...], $info) |
| 2 | Stream filter + LFI (php://filter/read=.../resource=...) |
| 3 | Remote image URL (/preview.php?url=attacker.com/malicious.jpg) |
$info arraygetimagesize() calls with php://filter wrappersUpgrade PHP to patched version. No workaround — patch required.
php -v # verify version
If upgrade blocked: strip APP1 from $info before returning to client, or disable php://filter in allow_url_fopen.
This tool is for authorized security testing only. Unauthorized use against systems you do not own or have explicit written permission to test is illegal.
| Mode | Action |
|---|
demo | Full exploit demo (default) |
gen | Generate malicious JPEG + PHP exploit code |
test | Generate test case JSON |
analyze | Generate JPEG + simulate + analyze leak |
flow | Print attack flow diagram |