Wysoka

OpenMage LTS: Phar Deserialization leads to Remote Code Execution

  • Ujawniono: 21.04.2026
  • Aktualizacja: 11.10.2026 10:22

PHP functions such as getimagesize(), file_exists(), and is_readable() can trigger deserialization when processing phar:// stream wrapper paths. OpenMage LTS uses these functions with potentially controllable file paths during image validation and media handling. An attacker who can upload a malicious phar file (disguised as an image) and trigger one of these functions with a phar:// path can achieve arbitrary code execution.

Metric Value Justification
Attack Vector (AV) Network Exploitable via file upload and web requests
Attack Complexity (AC) High Requires file upload + triggering phar:// access
Privileges Required (PR) None Some upload vectors don't require authentication
User Interaction (UI) None Exploitation is automatic once triggered
Scope (S) Unchanged Impacts the vulnerable component
Confidentiality (C) High Full system access via RCE
Integrity (I) High Arbitrary code execution
Availability (A) High Complete system compromise possible

Affected Products

  • OpenMage LTS versions < 20.16.1
  • All versions derived from Magento 1.x with these code paths

Affected Files

File Line Vulnerable Function
app/code/core/Mage/Core/Model/File/Validator/Image.php 72 getimagesize($filePath)
app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php 137 getimagesize($item->getFilename())
lib/Varien/Image.php 71 $this->_getAdapter()->open($this->_fileName)

Vulnerability Details

PHP's phar (PHP Archive) format stores metadata that is serialized. When PHP's stream wrapper functions access a file using the phar:// protocol, the metadata is automatically deserialized. This occurs even with seemingly safe functions like file_exists() or getimagesize().

A polyglot file can be crafted that is both a valid image (passing initial validation) and a valid phar archive containing malicious serialized objects. When the application later processes this file using phar://, the deserialization triggers a gadget chain leading to RCE.

Attack Flow

  1. Create polyglot file: Attacker creates a file that is both valid JPEG and valid PHAR
  2. Upload file: Attacker uploads the polyglot via product images, CMS media, or import
  3. Trigger phar:// access: Attacker causes the application to access the file using phar:// wrapper
  4. Code execution: PHAR metadata deserialization triggers gadget chain

Proof of Concept

php
<?php
// Create malicious phar file
class ExploitGadget {
    public $cmd = 'id > /tmp/pwned';
    function __destruct() {
        system($this->cmd);
    }
}

$phar = new Phar('exploit.phar');
$phar->startBuffering();
$phar->addFromString('test.txt', 'test');
$phar->setStub('<?php __HALT_COMPILER(); ?>');
$phar->setMetadata(new ExploitGadget());
$phar->stopBuffering();

// Rename to appear as image
rename('exploit.phar', 'exploit.jpg');

// When getimagesize('phar://path/to/exploit.jpg') is called,
// the ExploitGadget::__destruct() method executes

Remediation

Block phar:// paths before passing to vulnerable functions:

php
// Before (vulnerable)
[$imageWidth, $imageHeight, $fileType] = getimagesize($filePath);

// After (fixed)
if (str_starts_with($filePath, 'phar://')) {
    throw new Exception('Invalid image path.');
}
[$imageWidth, $imageHeight, $fileType] = getimagesize($filePath);

Additionally, ICO files (which cannot be re-encoded by GD) are now scanned for phar signatures:

  • __HALT_COMPILER(); - Required phar stub
  • <?php - PHP opening tag
  • <?= - PHP short echo tag

Additional hardening measures:

  1. ICO uploads removed: ICO file support is completely removed from new image uploads. This eliminates the polyglot attack vector entirely since all other image formats are re-encoded by GD, which strips any embedded phar metadata.

  2. Phar wrapper disabled: The phar:// stream wrapper is unregistered at application bootstrap, preventing any phar deserialization attacks regardless of code path.

  3. Cache deserialization hardening: All unserialize() calls on cached data now use allowed_classes => false as defense-in-depth.

Note: Existing uploaded ICO files will continue to work. Only new ICO uploads will be rejected. Users are encouraged to use PNG favicons for new uploads.

Workarounds

If immediate upgrade is not possible:

  1. Disable phar stream wrapper (if not needed):

    ini
    ; php.ini
    disable_functions = phar://

    Or in code:

    php
    stream_wrapper_unregister('phar');
  2. Strict upload validation: Implement additional validation beyond file extension

  3. File storage isolation: Store uploads outside web root with randomized names

  4. Web Application Firewall: Block requests containing phar:// in parameters

Credit

This vulnerability was discovered and responsibly disclosed by blackhat2013 through HackerOne.

Timeline

  • 2025-12-31: Vulnerability reported via HackerOne
  • 2026-01-21: Fix developed and tested

Source: https://hackerone.com/reports/3482926

Czego dotyczy

Kliknij technologię, aby zobaczyć wszystkie dotyczące jej podatności.

PlatformaPaczkaPodatne wersjePoprawka w wersji
Paczka Composer openmage/magento-lts < 20.17.0 20.17.0

Odnośniki

Ocena CVSS 8.1/10
Wektor CVSS
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
Słabość (CWE)
CWE-502
Platforma
Composer
Paczka
openmage/magento-lts
Ujawniono
21.04.2026
Aktualizacja
11.10.2026 10:22

Źródła i licencje

OSV / GitHub Advisory Database - GHSA-fg79-cr9c-7369 - CC BY 4.0

Historia podatności: openmage/magento-lts

Wszystkie opisane podatności tej paczki (Paczka Composer), od najnowszej. Widać, czy to jednorazowa wpadka, czy paczka, której trzeba pilnować.

Wszystkie (26) w archiwum
Wszystkich wpisów
26
Pierwsza → ostatnia
08.2020 05.2026
Bez poprawki
0
Wykorzystywana w atakach
0

Rozkład istotności

  • Krytyczna 3
  • Wysoka 12
  • Średnia 10
  • Niska 1

Ujawnienia w latach

  1. 2020: 2
  2. 2021: 4
  3. 2022: 0
  4. 2023: 8
  5. 2024: 2
  6. 2025: 2
  7. 2026: 8
Istotność:
  1. OpenMage LTS: Phar Deserialization leads to Remote Code Execution ten wpis
    Wysoka · 8.1 CVE-2026-25524 < 20.17.0 20.17.0
  2. Wysoka · 7.5 ghsa-9j5w-2cqc-cwj9 < 20.2.0 20.2.0
  3. Wysoka · 7.5 CVE-2023-41879 < 19.5.1, >= 20.0.0, < 20.1.1 19.5.1, 20.1.1
  4. Wysoka · 7.2 CVE-2021-41231 < 19.4.22, >= 20.0.0, < 20.0.19 19.4.22, 20.0.19
  5. Wysoka · 8.8 CVE-2021-41144 < 19.4.22, >= 20.0.0, < 20.0.19 19.4.22, 20.0.19
  6. Wysoka · 7.2 CVE-2021-41143 < 19.4.22, >= 20.0.0, < 20.0.19 19.4.22, 20.0.19
  7. Wysoka · 7.2 CVE-2021-39217 < 19.4.22, >= 20.0.0, < 20.0.19 19.4.22, 20.0.19
  8. Wysoka CVE-2021-32758 < 19.4.15, >= 20.0.0, < 20.0.13 19.4.15, 20.0.13
  9. Wysoka CVE-2021-32759 < 19.4.15, >= 20.0.0, < 20.0.13 19.4.15, 20.0.13
  10. Krytyczna · 9.1 CVE-2021-21427 < 19.4.13, >= 20.0.0, < 20.0.9 19.4.13, 20.0.9
  11. Krytyczna · 9.8 CVE-2021-21426 < 19.4.13, >= 20.0.0, < 20.0.9 19.4.13, 20.0.9
  12. Wysoka · 8.0 CVE-2020-15244 < 19.4.8, >= 20.0.0, < 20.0.4 19.4.8, 20.0.4
  13. Wysoka · 8.0 CVE-2020-15151 < 19.4.6, >= 20.0.0, < 20.0.2 19.4.6, 20.0.2

Dowiedz się, które podatności dotyczą Twojej aplikacji

Po podłączeniu integracji DockRay i włączeniu raportowania oprogramowania DockRay porównuje zgłoszone wersje komponentów ze znanymi podatnościami i powiadamia o potwierdzonych dopasowaniach. Zakres zależy od obsługiwanej technologii i dostępnych biuletynów.

Podłącz swoją aplikację
Newsletter DockRay

Bezpieczeństwo aplikacji w Twojej skrzynce

Najważniejsze podatności, konkretne zalecenia i praktyczne wskazówki dla Twoich aplikacji. Wybierz technologie i śledź to, co ma znaczenie dla Twojego projektu.

  • Codzienne zestawienie nowych podatności, także krytycznych.
  • Powiadomienia o ważnych aktualizacjach.
  • Praktyczne porady o bezpieczeństwie i monitoringu aplikacji.

Pozostaw puste, aby otrzymywać informacje o wszystkich technologiach.

Zapis jest bezpłatny. Wypiszesz się jednym kliknięciem w wiadomości.