Skip to content
XSS Write-up Intermediate

WordPress 5.8.2 Stored XSS Vulnerability

A stored cross-site scripting vulnerability in WordPress allowed an authenticated attacker with author privileges to inject a JavaScript payload into a post slug, which would execute when an administrator viewed the post listing. This could lead to session hijacking and privilege escalation, and with the bbPress plugin, unprivileged forum users could also exploit it.

sonarsource.com

Published on sonarsource.com

WordPress is the world’s most popular content management system that, according to w3techs, is used by over 40% of all websites. This wide adoption makes it a top target for cyber criminals who seek to compromise high-traffic websites or infect as many web servers as possible.

The author, on sonarsource.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 slug sanitisation function preserves URL-encoded characters, and a later truncation function decodes them but re-encodes only Unicode characters, leaving the decoded payload in the database.

Impact

An attacker could hijack an admin user session and escalate privileges, potentially leading to arbitrary code execution on the server; with bbPress installed, even unprivileged forum users could exploit it.

What the attacker needed

Author role privileges; or bbPress < 2.6.0 for unprivileged; admin views post listing

The fix

The vulnerability was fixed in WordPress 5.8.3 by modifying utf8_uri_encode() to optionally encode non-alphanumeric characters, and in bbPress 2.6.0 by adding server-side validation of topic title length.

How it was found

  1. Create two posts A and B.
  2. Set the slug of A to a URL-encoded JavaScript payload plus filling characters.
  3. Set the slug of B to the same as A.
  4. The payload ends up decoded in the database due to the unique slug generation process.
  5. An administrator visits the post listing page, and the payload executes.

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.

This is a stored cross-site scripting (XSS) bug. In a CMS like WordPress, users can create posts with a 'slug' (the part of the URL that identifies the post). The slug is supposed to be safe, but due to a flaw, an attacker could hide malicious JavaScript in it. When an admin later views a page that lists posts, the script runs in their browser, letting the attacker take over their 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.