pinafore icon indicating copy to clipboard operation
pinafore copied to clipboard

Tighten CSP for styles

Open nolanlawson opened this issue 6 years ago • 2 comments

The possibility is remote, but a malicious instance could inject CSS within status content or CWs to do a CSS keylogger, and grab things like CWs and toot text while you're composing it.

You would have to log into the instance yourself in order for this to work, there are no password fields in Pinafore, and also JS injection is disabled via CSP, so the potential damage is minimal. But we may as well reduce the attack surface.

Current challenge: lots of inline styles generated by both our app and Sapper that would need to be nonced/checksummed.

nolanlawson avatar Apr 19 '18 18:04 nolanlawson

JS injection is disabled via CSP,

Only a nit pick, but do not consider the CSP as disabling anything. It is a (admitted good and important) layer of defense, but priority number one is still to fix XSS issues.

But I agree with this issue. Inline styles should be removed, so you can remove 'unsafe-inline' from the style CSP diective. Or you can use nounces or hashes (like you do for the JS)…

https://csp-evaluator.withgoogle.com/ BTW is a good resource.

rugk avatar May 02 '19 06:05 rugk

Related: https://github.com/nolanlawson/pinafore/issues/776

Can't enable this CSP header without having all of our CSS file-based rather than injected as <style> tags.

nolanlawson avatar Mar 14 '21 03:03 nolanlawson