/

CVE-2026-40488

Severity:

HIGH RISK

(8.8)

Unrestricted File Upload in OpenMage LTS Product Custom

CVE-2026-40488

Analyzed

Vulnerability type

Category:

Unrestricted File Upload

CWE:

CWE-434

Impact:

Remote Code Execution via Malicious File Upload

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

OpenMage LTS versions prior to 20.17.0 contain an unrestricted file upload issue in the product custom option file upload feature, caused by an incomplete server-side blocklist that only forbids .php and .exe extensions.

Attackers can upload alternative PHP-executable file types into a web-accessible directory, which may lead to remote code execution if the media/custom_options/quote/ path is not configured to deny script execution.

Affected context

This vulnerability affects OpenMage LTS deployments that:

  • Enable product custom options with file uploads in the storefront
  • Rely on the built-in blocklist to prevent dangerous file types
  • Serve uploaded files directly from media/custom_options/quote/ or equivalent public media paths
  • Do not enforce server-side execution restrictions (e.g., PHP handler disabling) on the upload directory

Under these conditions, uploaded files with alternative PHP-executable extensions can be interpreted as code by the web server.

Exploit preconditions

  • Attack surface: Public web interface of the OpenMage LTS storefront, specifically product pages that expose file upload custom options.
  • Required access: Ability to interact with the storefront as a shopper or anonymous user (depending on store configuration); no administrative privileges are needed if uploads are publicly exposed.
  • Trigger point: Submitting a file through the custom option upload field with a PHP-executable extension that is not part of the restricted list.
  • Why exploitation is possible: The upload validation only blocks .php and .exe extensions, allowing other PHP-capable extensions (e.g., .phtml, .phar, .php3, .php4, .php5, .php7, .pht) to be stored under a web-accessible path where some server configurations will execute them as code.

Why this happens

The root cause is an incomplete, extension-based blocklist used to validate uploaded files in the product custom options feature.

Instead of enforcing a strict allowlist of safe content types and isolating uploads from code execution, the implementation only denies a small set of extensions (.php, .exe).

On many PHP-capable environments, various alternative extensions are still interpreted as executable scripts.

This maps to CWE-434: Unrestricted Upload of File with Dangerous Type, where user-controlled files can be uploaded to a location accessible by the server without adequate validation, sanitization, or execution isolation.

Potential impact

  • Execution of arbitrary PHP code in the context of the web server process
  • Full compromise of the Magento/OpenMage application and its database
  • Theft or manipulation of customer data and order information
  • Installation of web shells or backdoors for persistent access
  • Use of the compromised site for spam, phishing pages, or malware distribution
  • Lateral movement to other systems reachable from the application server

General mitigation guidance

Effective mitigation focuses on restricting both what can be uploaded and how uploads are served:

  • Prefer allowlist-based validation for file uploads:
  • Restrict to specific, non-executable file types (e.g., images, PDFs) using MIME type checks and safe extensions.
  • Reject any file with an extension or content type outside this allowlist.
  • Enforce non-executable upload directories:
  • Configure the web server (e.g., Apache, Nginx) so that media/custom_options/quote/ and other upload directories do not execute scripts, regardless of file extension.
  • Disable PHP and other script handlers in these folders.
  • Normalize and sanitize filenames:
  • Strip or normalize multiple extensions and unusual characters.
  • Avoid using user-supplied filenames directly when saving; generate server-side random names.
  • Apply least privilege on file system and runtime:
  • Ensure the web server account has only the permissions needed to write files, not to modify application code.
  • Separate code and content directories to limit the impact of uploaded files.
  • Use layered defenses:
  • Combine application-level validation with web server rules and, where appropriate, a WAF configured to flag suspicious upload patterns.

How teams detect issues like this

Detection can target both code-level patterns and runtime behavior:

  • Static analysis and code review:
  • Search for upload handling code that:
  • Uses hardcoded blocklists instead of allowlists.
  • Validates only file extensions without checking MIME type or content.
  • Writes uploaded files into web-accessible directories.
  • Flag any upload path under directories that are also configured for script execution.
  • Configuration and policy checks:
  • Automatically audit web server configs to ensure:
  • Upload directories have script execution disabled.
  • PHP (or similar) handlers are not enabled in media and asset paths.
  • Enforce policies that separate static media from executable code paths.
  • Runtime monitoring and logging:
  • Enable detailed logging for file uploads, capturing filename, size, and IP.
  • Monitor for uploads containing script-like extensions or suspicious content.
  • Use host-based or network-based security tools to detect execution of files from media/upload directories.
  • Security testing:
  • Incorporate file upload abuse scenarios into regular penetration tests and CI-based security testing.
  • Use automated scanners configured to probe for alternative executable extensions.

Sources

SourceLink
github.comgithub.com/OpenMage/magento-lts/security/advisories/GHSA-3j5q-7q7h-2hhv

Frequently asked

questions

Yes. If product custom option file uploads are exposed to the storefront and the upload directory allows script execution, an attacker can exploit this purely over HTTP without local access.

Not necessarily. If the store permits guests or unauthenticated users to upload files via product options, no login is required. If uploads are restricted to logged-in customers, basic account access is sufficient and no administrative role is required.

The safest pattern is to adopt a strict allowlist for file uploads, store uploaded files in directories where script execution is disabled, and ensure filenames are sanitized and decoupled from user input. These measures should be enforced in both application logic and web server configuration.

Treat all uploads as untrusted content, enforce allowlist-based validation, and design the architecture so that uploaded files are stored in non-executable locations. Complement this with regular security reviews of upload features, automated checks in CI for risky patterns, and configuration audits to ensure media directories cannot execute code.

Find out what's already
exploitable in your codebase.