Wagtail XSS + LocalStorage = Account Hijack
A stored cross-site scripting flaw in Wagtail's rich-text link handling let an editor inject a javascript: URL by tampering with the page-save request. When a moderator or admin clicked the link, attacker JavaScript wrote a malicious SVG into the browser's local storage, which later ran on admin pages and could redirect the login form to an attacker-controlled domain to steal credentials.
immersivelabs.com
Published on immersivelabs.com
Request a demo
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 server trusted the link type and URL fields in the page-save request without re-validating that an anchor link's URL still began with the expected prefix, so removing the prefix in transit left a javascript: URL.
Impact
An attacker with editor permissions could, if a moderator or admin clicked the crafted link, run JavaScript in that user's browser on admin pages and potentially capture their login credentials, leading to account takeover; the session cookie itself was protected by HttpOnly and a CSRF token was present, so direct session theft was blocked.
What the attacker needed
Editor-level account on Wagtail; victim clicks a crafted link; victim later visits admin pages
The fix
The XSS was fixed in Wagtail via a security advisory; the local storage behaviour was agreed not to be a vulnerability in itself.
How it was found
- Set up a local Wagtail instance using the Bakery demo project.
- Create or edit a page and add a link element, choosing the anchor link type.
- Set the URL to JavaScript code that writes to local storage.
- Save the page and intercept the request in Burp.
- Remove the # prefix from the URL in the request and forward it.
- Have a moderator or admin click the link, then visit admin pages to trigger the stored code.
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.
Wagtail is a content management system built on Python. A cross-site scripting (XSS) bug lets an attacker run their own JavaScript in someone else's browser. Here, a low-privileged editor could plant a link that, when clicked by an admin, stored malicious code in the browser's local storage, so it kept running on admin pages and could capture the admin's login details.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.