Skip to content
XSS Write-up Intermediate

From a Forgotten htmlspecialchars() to Full Admin Takeover The St

The refresh field in the iFrame invocation tag options was rendered into a single-quoted HTML attribute without htmlspecialchars(), so a crafted value could break out and inject an SVG onload handler. An attacker could send a link to an authenticated admin, run JavaScript in their session, read the CSRF token from the DOM, and create a new administrator account while deleting the original one.

kanon Follow

Published on medium.com

let me tell you a story about how one missing function call a single forgotten htmlspecialchars() turned into a full administrative takeover of an ad-serving platform used by publishers around the world.

kanon, on medium.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

The refresh option value was concatenated into a single-quoted HTML attribute without htmlspecialchars(), and addslashes() does not protect an HTML attribute context because a backslash is a literal character there.

Impact

An attacker could take over the ad server by creating a new admin and deleting the legitimate one, and because the platform serves code to real visitors, this could become a supply-chain distribution channel.

What the attacker needed

Victim is an authenticated admin or manager; victim opens a crafted link; attacker can reach the zone invocation page

The fix

The value should be encoded with htmlspecialchars() like the sibling fields already do.

How it was found

  1. Open a zone's invocation page and choose the iFrame tag type.
  2. Supply a crafted refresh value that closes the attribute and the input tag and adds an SVG onload handler.
  3. Send the resulting URL to an authenticated admin or manager.
  4. When the admin opens it, the script runs in their session and reads the CSRF token from the DOM.
  5. Use fetch with credentials to create a new administrator account.
  6. Use the same technique to delete the original administrator.

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 web page builds an HTML input field by pasting a value into it without escaping special characters. If that value contains a quote and a tag, the browser treats it as new HTML and runs any script inside it. Because the page is the admin panel, the script runs with the admin's permissions and can do anything the admin can do.

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.