Skip to content
XSS Write-up Intermediate

WordPress 4.2 Stored XSS

WordPress comments were vulnerable to stored cross-site scripting because overly long comments were truncated in the database, producing malformed HTML that allowed an attacker to inject JavaScript. An unauthenticated attacker could execute arbitrary code on the server if a logged-in administrator viewed the malicious comment.

klikki.fi

Published on klikki.fi

Current versions of WordPress are vulnerable to a stored XSS. An unauthenticated attacker can inject JavaScript in WordPress comments.

klikki, on klikki.fi

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 comment text was truncated at the database column size limit without proper sanitisation, causing malformed HTML that allowed injected attributes and JavaScript.

Impact

If a logged-in administrator viewed the comment, the attacker could execute arbitrary code on the server via the plugin and theme editors, change the administrator's password, or create new administrator accounts.

What the attacker needed

Ability to post a comment; comment must be approved or viewed by an admin; comment text must exceed 64 KB

The fix

WordPress 4.2.1 fixed the vulnerability; administrators could also disable comments and avoid approving any comments.

How it was found

  1. Post a comment containing a long HTML tag with an event handler and enough padding to exceed the database limit.
  2. Wait for the comment to be viewed by a logged-in administrator.
  3. The injected JavaScript executes in the administrator's browser.

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 stored cross-site scripting (XSS) flaw lets an attacker save malicious JavaScript in a website's database, so it runs in the browser of anyone who later views that content. Here, a very long comment was cut short when saved, which broke the page's HTML and let the attacker sneak in JavaScript. If an administrator viewed the comment, the script could take over their session and even run code 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.