challenge writeup content-type shenanigans
The challenge application reflected a user-controlled value into the Content-Type header and into an HTML attribute, allowing an attacker to manipulate the header to make the browser interpret the response as UTF-16 or multipart, bypassing the attribute filter and achieving script execution.
Published on gist.github.com
Clone this repository at <script src="https://gist.github.com/avlidienbrunn/8db7f692404cdd3c325aa20d09437e13.js"></script> - Save avlidienbrunn/8db7f692404cdd3c325aa20d09437e13 to your computer and use it in GitHub Desktop.
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
Impact
An attacker could execute arbitrary JavaScript in the context of the vulnerable page, potentially leading to session hijacking or other client-side attacks.
What the attacker needed
Victim visits a crafted URL
How it was found
- The attacker sends a request with a type parameter that includes a charset like UTF-16LE and a message containing null bytes and an encoded script tag.
- The server sets the Content-Type header to text/html;charset=UTF-16LE and reflects the message into the HTML attribute.
- The browser interprets the response as UTF-16, so the null bytes and encoded script tag become a valid script tag, bypassing the attribute filter.
- Alternatively, the attacker sets the type parameter to include a multipart boundary and a message with multipart parts containing HTML and script.
- The server sets the Content-Type header to multipart/x-mixed-replace with the boundary, and the browser renders the part with the script.
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.
The server put user input into the Content-Type header, which tells the browser how to read the page. By adding extra text, an attacker could make the browser read the page in a different encoding or as a multipart message, so that a harmless-looking input became a script that ran in the browser.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.