Chaining Stored XSS and CSRF in Typemill CMS: A Deep Dive into At
The Typemill CMS rendered page metadata without output encoding, allowing an attacker to inject script via a crafted API request. Combined with missing CSRF protection, an unauthenticated attacker could force an administrator's browser to store the payload and then exfiltrate session cookies.
Published on infosecwriteups.com
Flat-file CMS systems have grown rapidly in popularity due to their speed, simplicity, and lack of database overhead. One such popular CMS is Typemill, built on PHP and Slim framework.
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
The renderMeta() function concatenated user-controlled metadata into an HTML attribute without calling htmlspecialchars(), and the API endpoint lacked CSRF protection.
Impact
An unauthenticated attacker could force an administrator's browser to store a script that, when triggered, exfiltrates session cookies, leading to full session takeover.
What the attacker needed
Victim is an authenticated administrator; victim visits attacker-controlled page; attacker hosts a malicious website
The fix
The stored XSS was fixed in version 2.23.0 by wrapping the metadata in htmlspecialchars() with ENT_QUOTES; CSRF protection on state-changing API endpoints was recommended but not confirmed as implemented.
How it was found
- Identify the renderMeta() function in Assets.php that outputs metadata without encoding.
- Find the API endpoint POST /api/v1/meta that stores page metadata.
- Send a direct JSON request to that endpoint with a title or description containing a double quote and an event handler, bypassing the Vue.js frontend validation.
- Host a malicious page that auto-submits a request to the same endpoint, exploiting the lack of CSRF protection.
- When an authenticated administrator visits the malicious page, the payload is stored.
- Trigger the event handler (e.g., via console) to execute the script and exfiltrate cookies to an attacker-controlled listener.
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.
When a website shows information that users typed in, it must clean that text first so it cannot be interpreted as code. Here, the CMS put page metadata straight into the page without cleaning it, so an attacker could sneak in a script. Separately, the site did not check that requests changing settings really came from its own pages, so a malicious site could make an admin's browser send the request.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.