DEV Community

Discussion on: Missed Frontend Vulnerabilities (1): CSS is not as safe as you think!

Collapse
 
eldrimm profile image
Wesley van Drimmelen

Nice article! I just finished a small research on the same topic, so good to read yours aswell! I'd like to mention another solution: use strict CSP headers. That way you can block requests which are not allowed. Nice article, keep up te work!

Collapse
 
mizadmehr profile image
Mojtaba Izadmehr

Thanks! I didn't consider CSP while writing this, so it seems interesting.
Indeed the best way is to self-host every asset, and then use CSP to block any additional calls that you did not expect. Otherwise even if one of the CSS files is on a server they can still use this vulnerability.
I will update the article based on your suggestion:)

Collapse
 
xcs profile image
XCS

CSP is useful, but I don't think it is for this case as the initial resource and hack are loaded from the same domain.

Wouldn't it be more useful to add an integrity check to make sure the file is not updated? Do link nodes support the integrity attribute?

Collapse
 
eldrimm profile image
Wesley van Drimmelen • Edited

Using strict CSP you can block the background-image requests, which would be the malicious domain/api of the attacker. Using strict csp directives you can block these requests, that's how we're doing it at my current job