Magento Polyshell Unauthenticated File Upload To Rce In Magento Apsb25 94
Magento's REST API for guest cart items allows unauthenticated file uploads with arbitrary extensions because the image validation only checks MIME type and filename characters, not extension. An attacker could upload a polyglot PHP file that, if the web server configuration permits access and execution, leads to remote code execution.
slcyber.io
Published on slcyber.io
Magento remains one of the most popular e-commerce solutions in use on the internet, estimated to be running on more than 130,000 websites. It is also offered as an enterprise offering by Adobe under the name Adobe Commerce.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The image validation checks only that the file content is a valid image and that the filename lacks certain characters, but it does not verify that the file extension matches the image type, allowing a polyglot file with a .php extension to pass.
Impact
An attacker could achieve unauthenticated remote code execution if the web server is misconfigured to allow access and execution of uploaded files; otherwise, the file remains on disk and could become exploitable if configuration changes.
What the attacker needed
No authentication; web server misconfiguration allowing access/execution
How it was found
- Obtain a product SKU via the GraphQL API.
- Create a guest cart via a POST request to the REST API.
- Craft a polyglot file (e.g., a PNG with embedded PHP code) and base64-encode it.
- Send a POST request to the guest cart items endpoint with the file info in custom options, specifying a .php filename.
- Access the uploaded file at the predictable path under pub/media/custom_options/quote/ to check if it executes.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
This bug lets someone upload a file to a Magento store without logging in. The file can be a picture that also contains code, and if the server is set up to run such files, the attacker can run commands on the server. Normally, the server's configuration blocks access to these files, but if it is misconfigured, the attack works.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.