CSS Injection
Check List
Methodology
Black Box
Country Parameter
Log into the target site and intercept requests using the Bupr Suite tool
Then examine the requests and look for the country parameter, as shown below
https://example.com/search?q=a&country=BRIn the request, modify the country parameter to a random value and observe its reflection in a style attribute like this
<div class="language" style="background-image: url(/BR.svg)"><div>If the parameter value was inside a (..) we can escape using the ; character and write a new style and send the following malicious request
https://example.com/search?q=a&country=BR'); width: 9999px; height: 9999px; background: red; //And if the page changes, it is confirmed to be vulnerable and displayed in the html as follows
<div class="language" style="background-image: url(/BR.svg'); width: 9999px; height: 9999px; background: red; //)"><div>Base CSS injection
Access the target application
Navigate to the target page by clicking the relevant button
Observe the HTTP GET for /Home/TargetPage, and inspect the rendered form where the user can change “Color” and “Tag” of a text in that page
Submit the form with benign inputs (Color = “green”, Tag = “h3”) and inspect the HTTP POST to /Home/TargetPage. Confirm that the submitted values are reflected in the response HTML
Test for injection by providing a payload like Test for injection by providing a payload like "><h1>CSSInjection in the Color and Tag fields. Observe that the Color field is used without validation, whereas Tag input is validated
Refine the payload to something like \" onclick=prompt(8)> in the Color field to verify reflective XSS within the CSS context or style attribute
Exploit the CSS injection, inject attacker‑controlled CSS via the Color or style field and observe its effect on page rendering (overriding styles, altering visual appearance)
Potential XSS
Identify the target resource and confirm that this URL accepts user-controlled input that could potentially lead to CSS injection. The test could be like this
https://example.com/landings/libs/alert/alerts/exitpopup74/exit-popup.php?root=https://+YOUR SERVER+/&lang=enOn the attacker’s server, create the exit-popup.css file and insert the following code to test the CSS injection
div {
background-image: url("https://media.giphy.com/media/SggILpMXO7Xt6/giphy.gif");
background-color: #cccccc;
}Observe whether custom CSS is applied or reflected back — check for injected styles altering page rendering
White Box
Cheat Sheet
Last updated