A critical security vulnerability in Magento’s REST API, dubbed PolyShell by security firm Sansec, poses a significant risk of unauthenticated code execution and account takeover for e-commerce businesses. The flaw allows attackers to disguise malicious code as image files, potentially compromising sensitive data and customer accounts.
Magento REST API Vulnerability Poses Serious Threat
Sansec has alerted the e-commerce community to a serious security flaw affecting Magento Open Source and Adobe Commerce versions up to 2.4.9-alpha2. This vulnerability, codenamed PolyShell, exploits the Magento REST API’s handling of custom product options. Attackers can leverage this weakness to upload arbitrary executable files, leading to severe security breaches.
The exploit hinges on a technique where malicious code is disguised within image files. While there is currently no evidence of this specific vulnerability being exploited in the wild, its potential impact is substantial. The Dutch security firm detailed that the issue arises from how Magento processes embedded file data within the REST API when a product option is configured as a file type.
How the PolyShell Vulnerability Works
According to Sansec, when a product option is set to accept a file upload, Magento processes an object that includes base64-encoded file data, a MIME type, and a filename. This file is then written to the server within the `pub/media/custom_options/quote/` directory. The way this process is handled creates an opening for attackers.
Depending on the web server’s configuration, this flaw can be exploited in two primary ways: remote code execution via PHP uploads, or account takeover through stored Cross-Site Scripting (XSS) attacks. Both scenarios present a critical threat to the integrity and security of online stores and their customers’ data. The unrestricted file upload capability is the core of the problem.
Adobe’s Response and Mitigation Strategies
Adobe acknowledged and addressed the issue in the 2.4.9 pre-release branch as part of the APSB25-94 security advisory. However, a standalone patch for currently deployed production versions of Magento is not yet available, leaving many stores exposed.
Sansec noted that while Adobe does offer sample web server configurations that can significantly mitigate the fallout from this vulnerability, many e-commerce sites operate with custom configurations provided by their hosting providers. This reliance on custom setups means that many stores may not have implemented the necessary protections to prevent exploitation.
Recommended Steps for E-commerce Storefronts
To protect against potential exploitation of the PolyShell vulnerability, Sansec strongly advises e-commerce businesses to implement several immediate mitigation steps. These measures are crucial for safeguarding online stores against unauthorized access and code execution.
First, it is imperative to restrict direct access to the upload directory, specifically `pub/media/custom_options/`. This involves verifying that web server configurations, such as those for Nginx or Apache, explicitly prevent any unauthorized access to this directory. Following this, businesses should conduct thorough scans of their stores for any existing web shells, backdoors, or other forms of malware that might have been introduced through this or other vulnerabilities.
Sansec further cautioned that simply blocking access to the directory will not prevent uploads. Therefore, without a specialized Web Application Firewall (WAF) in place, malicious code could still be uploaded. Businesses relying on custom server configurations should prioritize implementing robust security measures to bridge this gap. The ongoing threat of web security exploits necessitates continuous vigilance and proactive security practices.
The immediate future for Magento users will likely involve Adobe releasing a comprehensive patch for all affected production versions. Until then, e-commerce operators must rely on strict server-side configurations and advanced WAF solutions to defend against the PolyShell vulnerability and similar threats.

