Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Add 'unsafe-inline' to style-src in CSP to enable server-rendered inline React styles #2436

Merged
merged 1 commit into from
May 16, 2017

Conversation

lmorchard
Copy link
Contributor

Issue #2434

@lmorchard
Copy link
Contributor Author

Not 100% happy to just copypasta the CSP rules between shell & JS files, but couldn't think of an easy way to DRY that out.

…ine React styles

- Also inject content-security-policy header in the local dev server

- See also: facebook/react#5878 (comment)

Issue mozilla#2434.
Fixes mozilla#2432.
@fzzzy
Copy link
Contributor

fzzzy commented May 16, 2017

Let's go ahead and merge this now, but try to move the inline styles out into css files and remove unsafe-inline styles before the sprint is over.

@fzzzy fzzzy merged commit 2ae82da into mozilla:master May 16, 2017
@elimisteve
Copy link

elimisteve commented Mar 17, 2018

Doesn't adding unsafe-inline allow for attacks like the CSS-only keylogger found at https://no-csp-css-keylogger.badsite.io/ ?

In an attempt to help decrease the maximum severity of the problems caused by injections, keeping the CSS-related CSP settings safe is pretty important.

@chuckharmston
Copy link

CC @april for the above comment.

@april
Copy link

april commented Mar 19, 2018

There is a particular pattern that can cause that issue. Are you setting value directly on form fields with each keypress?

@elimisteve
Copy link

@april If one sets the value of a form field onChange while CSP allows for unsafe-inline, is that dangerous?

@april
Copy link

april commented Apr 17, 2018

Yes, that is exactly the pattern that can be dangerous. I would recommend not doing that, especially for sensitive fields like credit cards or passwords. For those, I recommend letting them be uncontrolled.

Note that you can still do things with them onSubmit and you can check and validate their values onChange, just don't send the current value back into the field's value.

(sorry for not responding for a while, I was out of town)

@lmorchard
Copy link
Contributor Author

FWIW, the only form submission we have on the site is for an email newsletter signup. Not entirely harmless, but also not a credit card or password field

@april
Copy link

april commented Apr 17, 2018

In that case, you can probably just do your normal controlled inputs and not worry about it too much. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants