Skip to content
RCE Write-up Advanced

Magento – RCE & Local File Read with low privilege admin rights

Two vulnerabilities in Magento required a low-privilege admin account: a path traversal in product layout XML allowed a .phtml file uploaded via custom options to be executed as PHP, and a path traversal in the email template CSS directive allowed reading arbitrary local files. An attacker with such an account could achieve remote code execution or read sensitive files.

Daniel Le Gall Follow

Published on blog.scrt.ch

I regularly search for vulnerabilities on big services that allow it and have a Bug Bounty program. Here is a second paper which covers two vulnerabilities I discovered on Magento, a big ecommerce CMS that’s now part of Adobe Experience Cloud.

Daniel Le Gall (@Blaklis_), on blog.scrt.ch

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

Likely the file path validation only checked that the path string started with an allowed directory, without resolving '..' sequences, and the CSS directive did not sanitise path traversal characters.

Impact

An attacker with low-privilege admin rights could execute arbitrary commands on the server or read local files, potentially leading to full compromise.

What the attacker needed

Low-privilege admin account; ability to create products; ability to create email templates

The fix

The vulnerabilities were fixed in Magento 2.3.0, 2.2.7 and 2.1.16.

How it was found

  1. Log in with a low-privilege admin account that can create products.
  2. Create a product with a custom file option allowing .phtml uploads and stock to order one.
  3. On the frontend, upload a .phtml file and add the product to the cart.
  4. Retrieve the full application path by causing a cURL error in the product gallery image retrieval.
  5. In the product design tab, add layout XML that calls fetchView with a path traversal to the uploaded .phtml file.
  6. Visit the product page on the frontend to execute the code.

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.

A low-privilege admin user could abuse two features: product layout settings and email templates. By tricking the system into loading files from outside the intended folders, they could run their own code on the server or read files that should be private.

What is RCE?

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.

More from Magento

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.