CSS Injection in Real Bug Bounty Engagements: A Reproducible Patt
The application allowed users to inject arbitrary CSS into their public profile theme, and the injected styles were not sanitised. An attacker could use CSS attribute selectors to conditionally load external resources based on the value of a hidden CSRF token, thereby exfiltrating the token character by character to an attacker-controlled server.
Published on medium.com
This write-up demonstrates an authenticated, low-privileged CSS Injection vulnerability leading to a high-severity Side-Channel Data Exfiltration path. While the target application enforced a rigid Content Security Policy (CSP) that successfully neutralized typical JavaScript execution paths (XSS), it failed to…
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 exfiltrate sensitive tokens such as CSRF tokens from a victim's session, potentially leading to account takeover or other unauthorized actions, although the attack requires the victim to visit the attacker's profile and may be limited by browser throttling.
What the attacker needed
Attacker has a low-privileged account; victim visits attacker's profile; attacker controls an OOB listener
The fix
The application should disallow raw stylesheet tags and enforce strict value filters that restrict style updates to predefined CSS properties, explicitly rejecting data-routing functions such as url(), @import, or image-set().
How it was found
- Submit a baseline CSS rule to confirm that arbitrary style injection is possible.
- Identify a hidden input field containing a sensitive token (e.g., CSRF token) in the DOM.
- Set up an out-of-band listener to receive HTTP requests.
- Craft CSS rules using attribute selectors that trigger a background-image request to the listener only when the token value starts with a guessed prefix.
- Iteratively update the CSS payload to guess the next character based on which request was received, repeating until the full token is extracted.
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.
CSS is normally used to style web pages, but if a site lets you add your own CSS without cleaning it, you can use special CSS rules that check the value of hidden form fields. By making the page load an image from a server you control only when a guessed character matches, you can slowly reveal secret values like anti-forgery tokens. This is called a side-channel attack because it leaks information indirectly through network requests.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.