Skip to content
XSS Write-up Intermediate

Exploiting an XSS Vulnerability in WordPress to Create an Admin A

A WordPress theme allowed unauthenticated users to inject JavaScript into a public page. When an administrator visited that page, the injected script read the create-user nonce and submitted a request that created a new administrator account.

JeninSutradhar Follow

Published on medium.com

In this PoC, I demonstrate how to exploit a WordPress theme or plugin that is vulnerable to XSS. The injected script will:

JeninSutradhar, 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

Likely the OneTone theme failed to sanitise or escape user-supplied input on a publicly accessible page, letting injected script run in an administrator's browser.

Impact

An attacker could create a new administrator account and gain full control of the WordPress site, but only if an administrator visits the injected page while logged in.

What the attacker needed

Vulnerable WordPress site; XSS flaw in a theme or plugin; admin visits the injected page

The fix

The theme should be updated or patched so user-supplied input is sanitised and escaped, and the site owner should keep themes and plugins up to date.

How it was found

  1. Find an XSS flaw in the OneTone theme that lets unauthenticated users inject JavaScript into a public page.
  2. Write a script that fetches the user-new page, extracts the create-user nonce, and posts a request to create an administrator.
  3. Host the script locally with a simple Python HTTP server.
  4. Inject a script tag pointing at the hosted file into the vulnerable page.
  5. Log in as an administrator and visit the vulnerable page so the script runs.
  6. Check the Users section to confirm the new administrator account exists.

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 website can be tricked into running code written by an attacker if it shows user-supplied content without cleaning it. Here the attacker's JavaScript ran inside the logged-in administrator's browser, so it could act as that admin. It used a one-time security token from the admin's own session to add a new admin account.

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.