Skip to content

Conversation

@hacdias
Copy link
Member

@hacdias hacdias commented Dec 11, 2018

Prevent any URL that is not from our app to open inside one of our windows. This takes into account the recommendations of Electron's team.

Update: content security policy headers seem not to work when web security is set to false.

License: MIT
Signed-off-by: Henrique Dias <[email protected]>
License: MIT
Signed-off-by: Henrique Dias <[email protected]>
@ghost ghost assigned hacdias Dec 11, 2018
@ghost ghost added the in progress label Dec 11, 2018
@hacdias hacdias requested a review from olizilla December 11, 2018 15:57
Copy link
Member

@olizilla olizilla left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Near PR. Need to dig into what the correct CSP is for web ui. That could be implemented as a meta tag and PR'd on webui too.

callback({ // eslint-disable-line
responseHeaders: {
...details.responseHeaders,
'Content-Security-Policy': ['default-src \'none\'']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you come to pick this as the CSP? I just ran the CSP Labratory plugin on Web UI and it came up with

 default-src 'none'; connect-src 'self' http://127.0.0.1:5001/api/v0/config/show http://127.0.0.1:5001/api/v0/get http://127.0.0.1:5001/api/v0/id http://127.0.0.1:5001/api/v0/object/get http://127.0.0.1:5001/api/v0/stats/bw http://127.0.0.1:5001/api/v0/swarm/peers; font-src 'self'; img-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' 

which i think we can trim down, but it's a start.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olizilla maybe it could be trimmed down to:

default-src 'none'; connect-src 'self'; font-src 'self'; img-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' 

I set it to default-src none because it was the less permissive of all and it worked. Which now leads me to think that disabling web security might disable CSP. I couldn't find any info about it. But it is in fact weird that setting the default-src to none doesn't change anything. I'll investigate.

License: MIT
Signed-off-by: Henrique Dias <[email protected]>
@hacdias
Copy link
Member Author

hacdias commented Dec 12, 2018

@olizilla just updated it here.

@olizilla
Copy link
Member

were you able to verify if it is applied when webSecurity is false?

@hacdias hacdias merged commit 120508e into master Dec 12, 2018
@ghost ghost removed the in progress label Dec 12, 2018
@hacdias hacdias deleted the security branch December 12, 2018 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants