Skip to content
XSS Write-up Advanced

Who is affected?

A logic flaw in the escapeHtmlWithLinks() sanitisation method allowed an unauthenticated attacker to inject a stored XSS payload into order cancellation notes. When an admin viewed the cancelled order, the payload executed and could hijack the admin session, after which an authenticated Phar deserialization vulnerability could be exploited to achieve remote code execution.

blog.ripstech.com

Published on blog.ripstech.com

A successful attack enables an unauthenticated adversary to persistently inject a JavaScript payload into the administrator backend of a Magento store. When triggered, this JavaScript payload can then perform automated exploit steps in the browser of a victim.

The author, on blog.ripstech.com

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 escapeHtmlWithLinks() method replaced anchor tags with placeholders before escaping the rest of the string, then reinserted the sanitised links with vsprintf(), allowing an attacker to break out of an HTML attribute context because the placeholder position was not considered.

Impact

An unauthenticated attacker could hijack an admin session and then achieve remote code execution, leading to full store takeover and potential financial harm, though the exploit requires the store to use the Authorize.Net module and the admin to view the cancelled order.

What the attacker needed

Magento store with Authorize.Net module enabled; Vulnerable Magento version (<=2.3.1, <=2.2.8, <=2.1.17); Victim (admin) views the cancelled order; No authentication needed for initial XSS

The fix

The escapeHtmlWithLinks() method should be fixed to properly handle anchor tags within attribute contexts, and the Phar deserialization should be addressed by validating file paths; patches were made available in Magento versions 2.3.2, 2.2.9 and 2.1.18.

How it was found

  1. Start an order using the Authorize.Net payment module and then cancel it, providing a crafted cancellation note.
  2. The crafted note contains an anchor tag placed inside an HTML attribute, which bypasses escapeHtmlWithLinks() and injects an event handler.
  3. When an administrator reviews the cancelled order, the injected JavaScript executes in their browser.
  4. The JavaScript hijacks the admin session and uses it to send a request to the WYSIWYG editor controller with a phar:// stream wrapper.
  5. The phar:// wrapper triggers PHP object injection, and chaining POP gadgets leads to remote code execution.

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.

The shop's code tried to clean up user input to remove dangerous HTML, but a mistake in one cleaning function let an attacker sneak in a script. That script ran in the browser of a shop administrator who looked at a cancelled order, letting the attacker take over the admin's session. With admin access, the attacker could then use another bug to run commands on the server.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.