Summary
OpenMage LTS is vulnerable to unsafe PHP object deserialization through PHAR stream wrappers used in image validation and media handling.
If an attacker can upload a malicious PHAR file disguised as an image and cause functions like getimagesize(), file_exists(), or is_readable() to operate on a phar:// path, they may achieve arbitrary code execution on the server.
Affected context
This issue arises in OpenMage LTS installations that process user-supplied media or images and then pass file paths into PHP functions that implicitly trigger PHAR metadata parsing.
The vulnerability is relevant when:
- Users or integrations can upload images or media files
- The application stores uploaded files in locations that may contain PHAR archives
- File validation and image-handling routines rely on
getimagesize(),file_exists(),is_readable(), or similar functions without constraining the use ofphar://stream paths
Exploit preconditions
- Attack surface: Web-facing media upload and image-processing endpoints.
- Required access: Ability to upload or cause storage of attacker-controlled files to locations later processed by OpenMage.
- Trigger point: Execution of PHP functions such as
getimagesize(),file_exists(), oris_readable()on a path that resolves to aphar://stream targeting the malicious file. - Why exploitation is possible: PHP's PHAR implementation parses metadata using unserialize-like behavior whenever a PHAR archive is accessed via
phar://. When OpenMage passes controllable paths into these functions, it inadvertently causes deserialization of attacker-controlled metadata, enabling execution of gadget chains present in the application or its dependencies.
Why this happens
The core issue stems from relying on generic filesystem and image inspection functions that implicitly trigger PHAR deserialization when given phar:// URLs.
Under the hood, accessing a PHAR archive via phar:// causes PHP to process the archive's metadata using object deserialization semantics. In OpenMage LTS, user-influenced file paths can be passed to functions such as getimagesize(), file_exists(), and is_readable() without first ensuring that PHAR wrappers are disallowed.
This aligns with CWE-502: Unsafe Deserialization, where untrusted data (PHAR metadata) is deserialized, allowing attackers to invoke gadget chains in the codebase. The pattern is not a logic error in the functions themselves but in the assumption that they are safe to call on arbitrary, user-controllable paths.
Potential impact
- Execution of arbitrary PHP code in the context of the web server process
- Complete compromise of the OpenMage application and underlying storefront data
- Theft or modification of customer information, including orders and account details
- Tampering with product catalogs, prices, and checkout flows
- Use of the compromised server as a pivot point for broader infrastructure attacks
General mitigation guidance
Effective mitigation centers on reducing trust in user-controlled file paths and avoiding implicit PHAR deserialization:
- Treat all uploaded file paths as untrusted and strictly constrain where and how they are used.
- Prevent the use of
phar://stream wrappers for application-controlled file operations, for example by validating schemes and rejecting or normalizing paths that include unexpected wrappers. - Enforce strict content-type and file-format validation for uploads, using robust server-side checks that do not rely solely on
getimagesize()or similar functions. - Consider isolating upload handling into a reduced-privilege environment (e.g., separate process or container) so that even if deserialization occurs, the blast radius is limited.
- Apply the principle of least privilege to the web server and PHP runtime, minimizing filesystem and database permissions.
- Incorporate a secure-by-default media handling layer that does not rely on functions known to trigger PHAR processing on attacker-controllable input.
How teams detect issues like this
Organizations can look for this bug pattern using a combination of static and process-level detection:
- Static analysis: Flag calls to
getimagesize(),file_exists(),is_readable(), and similar filesystem APIs when their arguments can be influenced by user input or file uploads, especially wherephar://is not explicitly excluded. - Code review: Examine image validation, upload, and media-management flows for:
- Direct or indirect use of user-controlled paths
- Lack of path normalization or scheme validation
- Assumptions that certain file extensions guarantee safe content
- Configuration / policy enforcement: Implement platform policies that forbid
phar://usage in high-risk contexts and enforce safe upload handling patterns in shared libraries and frameworks. - Runtime monitoring: Instrument logging around upload endpoints and file operations to detect unexpected
phar://paths or anomalous PHAR access patterns, then correlate with security alerts.

