A proof-of-concept demonstrating how to steal CSRF tokens via CSS injection without using iFrames, enabling client-side attacks.
dxa4481/cssInjection is a proof-of-concept security demonstration that shows how attackers can steal CSRF tokens from websites using CSS injection without relying on iFrames. It exploits CSS attribute selectors to leak sensitive data from HTML attributes and uses pop-up windows combined with Service Workers for client-side exfiltration. The project highlights a practical attack vector that works even on sites protected against framing and XSS.
Security researchers, penetration testers, and web developers focused on understanding client-side vulnerabilities and CSS-based attack techniques. It's also relevant for those building or auditing web applications with CSRF protections.
This project provides a novel, documented method for CSS injection attacks that bypasses iFrame limitations, offering a realistic demonstration of how CSRF tokens can be stolen entirely client-side. It serves as an educational tool to raise awareness about the risks of rendering untrusted CSS.
Stealing CSRF tokens with CSS injection (without iFrames)
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses pop-up windows instead of iFrames to bypass common framing restrictions like X-Frame-Options headers, making the attack applicable to modern websites that block framing, as detailed in the 'Without iFrames' section.
Leverages Service Workers to intercept resource requests without a backend server, reducing setup complexity and highlighting a purely client-side attack vector, as explained in 'Without a backend server'.
Shows how CSRF tokens can be stolen in approximately 10 seconds after user interaction, providing a tangible example of the speed and efficiency of this CSS-based attack.
Clearly breaks down how CSS attribute selectors can abuse sensitive data in HTML attributes, with practical code snippets and a demo, making it accessible for security researchers.
The demo only works in Chrome due to reliance on Service Workers and experimental features like foreign fetch, which the README admits by stating 'ONLY TESTED IN CHROME RIGHT NOW'.
Requires manual configuration of pop-ups, Service Workers, and same-origin pages for the demo, making it less accessible for quick experimentation without deep technical knowledge.
Focuses on reflected CSS injection, which may not be prevalent in all web applications, and the attack depends on specific vulnerabilities that are often mitigated in practice.