
Differential PoC lab for CVE-2026-128046: unauthenticated .phar upload via OpenMage product File custom options, with check, exploit, probe and mitigation modes.
| CVE | CVE-2026-128046 (GHSA-4fxg-469f-r6fc, High 8.1 CVSS v3.1) |
| Component | OpenMage LTS — Mage_Catalog_Model_Product_Option_Type_File::_validateUploadedFile() and general/file/protected_extensions |
| Affected | < 20.18.2, 21.0.0-beta1–beta2 (and everything before 20.17.0 via forbidden_extensions only) |
| Fixed in | 20.18.2 / 20.19.0 / 21.0.0-beta3 |
| CWE | CWE-434 (Unrestricted Upload of File with Dangerous Type), CWE-184 (Incomplete List of Disallowed Inputs) |
| Impact | An unauthenticated visitor uploads a .phar through a product File custom option and executes it by fetching its predictable media path — full application-server compromise where the web server maps .phar to PHP and serves media/custom_options/ |
| Vector | Storefront add-to-cart with a File custom option (no account required) |
| Trigger | Upload with extension .phar (also .php8, .phps) accepted by the blocklist; served path media/custom_options/quote/<c1>/<c2>/<md5>.phar |
| Credit | vilaysone (missing extensions, via HackerOne), @arpitjain099 (guest route), @4n86rakam1 (code execution on a distribution-default Apache stack); fix by @colinmollenhour, reviewed by @Hanmac |
The default upload blocklist general/file/protected_extensions covered php through php7, pht and phtml — but not phar, php8 or phps. Since a product File custom option with an empty allowed-extension list (the default) accepts any guest upload, an unauthenticated visitor can store a .phar at a fully predictable path and fetch it. Where the web server maps .phar to the PHP handler and serves media/custom_options/ — nginx always ignores the directory's .htaccess; Debian/Ubuntu Apache maps .phar by default — the fetch executes the file. This lab reproduces the complete chain against source builds of v20.18.0 (vulnerable) and v20.18.2 (fixed) behind an nginx tier that models exactly that configuration: the vulnerable build accepts the guest .phar upload and serves it executed to an unauthenticated fetcher; the fixed build rejects the upload outright.
_validateUploadedFile() rejects storefront uploads whose extension is in the general/file/protected_extensions config list (or the store-level catalog/custom_options/forbidden_extensions). That list protected php–php7, pht, phtml and others but omitted phar, php8 and phps. The upload path is deterministic:
$fileName = Mage_Core_Model_File_Uploader::getCorrectFileName($fileInfo['name']);
$dispersion = Mage_Core_Model_File_Uploader::getDispretionPath($fileName);
$filePath = $dispersion;
$fileHash = md5(file_get_contents($fileInfo['tmp_name']));
$filePath .= DS . $fileHash . '.' . $extension;
$fileFullPath = $this->getQuoteTargetDir() . $filePath;
— i.e. media/custom_options/quote/<first char of name>/<second char of name>/<md5(content)>.<ext> (the dispersion characters are the file name's own first two characters: shell.phar → s/h/…). Every term is known to the uploader before the request.
The media/custom_options/.htaccess that would block Apache stacks only ships with fixed releases (before, it was written on the first upload), nginx ignores .htaccess entirely, and Debian/Ubuntu libapache2-mod-php maps .phar to the PHP handler by default. The violated invariant: the blocklist must include every extension the PHP handler executes.
| service | image | role |
|---|---|---|
db | mariadb:10.11 | shared site databases |
openmage-vuln | source build of v20.18.0 | vulnerable side |
openmage-fixed | source build of v20.18.2 | fixed side |
poc | — | stdlib Python driver |
Both OpenMage builds are built from the official release tags (composer install + the CLI installer with automatic database setup). A synthetic product with a File custom option (allowed-extension list empty) is seeded into each database by the image entrypoint. The nginx tier serves /media/ — including custom_options, with no .htaccess support — and maps .php/.phar to PHP-FPM, which is the advisory's exploitation precondition (AC:H). Every container is CPU/memory bounded on the isolated cve128046lab network.
./run-lab.sh build # both OpenMage source builds + PoC runner (~minutes)
./run-lab.sh sweep # exploit / probe / mitigation / check (restarts vuln for clean runs)
./run-lab.sh down
Single mode:
podman run --rm --network=cve128046lab cve-2026-128046-poc:local exploit
poc/poc.py — stdlib-only Python, four modes:
| mode | purpose |
|---|---|
check | classify one target: guest upload of the canary .phar + unauthenticated fetch of the predicted path (one canary cart item; documented side effect) |
exploit | full differential: the vulnerable build must accept the upload and serve it executed; the fixed build must reject it (no file stored) |
probe | extension inventory: .php/.php5/.pht/.phtml rejected (legacy blocklist holds) while .phar/.php8/.phps are stored and served through the PHP handler — matching the advisory's exact gap |
mitigation | the published workarounds: upgrade (fixed build rejects the upload), server-side deny of /media/custom_options/, no .phar handler mapping, explicit allowed-extension list on the custom option |
Exit codes: 0 safe / workaround validated, 1 vulnerable, 2 target unreachable, 3 inconclusive, 4 internal error.
The storage path is computed before the request from the advisory's own formula (dispersion = the file name's first two characters; file name = md5 of the content), so the fetch needs no discovery step.
| reproduction path | vulnerable v20.18.0 | fixed v20.18.2 | evidence |
|---|---|---|---|
guest add-to-cart upload of shell.phar | accepted; stored at media/custom_options/quote/s/h/<md5>.phar | rejected — no file stored, cart empty | evidence/poc-exploit.txt |
| unauthenticated fetch of the predicted path | 200 — PHP executed, body POC-RCE-MARKER-128046[vuln] | 404 (File not found.) | evidence/poc-exploit.txt |
extension inventory (.php .php5 .pht .phtml) | rejected — legacy blocklist holds | — | evidence/poc-probe.txt |
extension inventory (.phar .php8 .phps) | stored and served through the PHP handler | — | evidence/poc-probe.txt |
| mitigation (upgrade) | — | upload rejected; chain closed | evidence/poc-mitigation.txt |
podman compose; --cpus 2 --memory 4g per container; isolated cve128046lab network..phar handler + serving /media/) is the advisory's AC:H precondition and is provided by the lab's nginx tier.