-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSP (Content-Security-Policy) Support #508
Comments
Another reference https://content-security-policy.com/ Edit: update to be more secure and add githubusercontent.com |
Okay, images are saved. Using img-src *; is fine, as its only loading images and the browser itself should handle issues there. However, the issue now comes up with the following error in console after a reload of the page The FetchEvent for "https://repository-images.githubusercontent.com/14822868/751ec900-ae2b-11ea-8fbb-1ee16400fa8f" resulted in a network error response: an object that was not a Response was passed to respondWith(). FetchEvent is the response (and that gave rise to your respondWith error). the bug is going to be on the request side. The service worker should use fetch with a Request() rather than a url string and then as part of the Request, specify the RequestDestination https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith This allows Edit: added some more info https://stackoverflow.com/questions/57872284/content-security-policy-violations-on-seemingly-valid-urls |
Inline issue after 4.33 update https://imgur.com/oibXCGb |
Current working headers: nginx: Apache: |
@wylel Would it be an idea to set these in either or res->header in mojo? |
@stigtsp I will have to look at Mojo as im not familiar with it. i will update when I do. |
I’m not entirely sure, but I think you can add it here: https://github.com/Nordaaker/convos/blob/00a95979a13762b502b07ff6d8d7257247ceda0c/lib/Convos.pm#L126 Let me know if that line does not make sense. https://convos.chat/doc/develop#starting-the-application shows how to start a “live” development server. Note however that changes in the lib/ directory will cause Convos to reconnect all the IRC connections. Ask on freenode if you want a demo IRC server to test against that doesn’t mind a lot of reconnects. |
I think this makes a lot of sense to do it there, not relying on nginx. |
Another user had issues with CSP today, so I was wondering if I could add the header from #508 (comment) to Convos? Is there any risk involved in doing so? I also wonder how difficult it would be to bundle the Google fonts... Maybe I should just do that. I still don't want to bundle the Twitter emojis though, since there's so many of them. |
Any breakage should be apparent in the console logs. I think it's nice to add some CSP rules. :) |
Let me finally test it and see, if you haven't already. Been busy, sorry about that. Theoretically this should be fine. |
Ubuntu Mono, UbuntuMono-Regular, https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc3CsTYl4BOQ3o.woff2 Ubuntu Mono, UbuntuMono-Regular, https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc3CsTYl4BOQ3o.woff2 Ubuntu Mono, UbuntuMono-Regular, https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc-CsTYl4BOQ3o.woff2 Ubuntu Mono, UbuntuMono-Regular, https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc2CsTYl4BOQ3o.woff2 Ubuntu Mono, UbuntuMono-Regular, https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc5CsTYl4BOQ3o.woff2 Ubuntu Mono, UbuntuMono-Regular, https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc0CsTYl4BOQ3o.woff2 Ubuntu Mono, UbuntuMono-Regular, https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc6CsTYl4BO.woff2 PT Sans, PTSans-Regular, https://fonts.gstatic.com/s/ptsans/v11/jizaRExUiTo99u79D0-ExcOPIDUg-g.woff2 PT Sans, PTSans-Regular, https://fonts.gstatic.com/s/ptsans/v11/jizaRExUiTo99u79D0aExcOPIDUg-g.woff2 PT Sans, PTSans-Regular, https://fonts.gstatic.com/s/ptsans/v11/jizaRExUiTo99u79D0yExcOPIDUg-g.woff2 PT Sans, PTSans-Regular, https://fonts.gstatic.com/s/ptsans/v11/jizaRExUiTo99u79D0KExcOPIDU.woff2 PT Sans Bold, PTSans-Bold, https://fonts.gstatic.com/s/ptsans/v11/jizfRExUiTo99u79B_mh0OOtLR8a8zILig.woff2 PT Sans Bold, PTSans-Bold, https://fonts.gstatic.com/s/ptsans/v11/jizfRExUiTo99u79B_mh0OqtLR8a8zILig.woff2 PT Sans Bold, PTSans-Bold, https://fonts.gstatic.com/s/ptsans/v11/jizfRExUiTo99u79B_mh0OCtLR8a8zILig.woff2 wget https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc3CsTYl4BOQ3o.woff2 wget https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc-CsTYl4BOQ3o.woff2 wget https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc2CsTYl4BOQ3o.woff2 wget https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc5CsTYl4BOQ3o.woff2 wget https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc0CsTYl4BOQ3o.woff2 wget https://fonts.gstatic.com/s/ubuntumono/v9/KFOjCneDtsqEr0keqCMhbCc6CsTYl4BO.woff2 wget https://fonts.gstatic.com/s/ptsans/v11/jizaRExUiTo99u79D0-ExcOPIDUg-g.woff2 wget https://fonts.gstatic.com/s/ptsans/v11/jizaRExUiTo99u79D0aExcOPIDUg-g.woff2 wget https://fonts.gstatic.com/s/ptsans/v11/jizaRExUiTo99u79D0yExcOPIDUg-g.woff2 wget https://fonts.gstatic.com/s/ptsans/v11/jizaRExUiTo99u79D0KExcOPIDU.woff2 wget https://fonts.gstatic.com/s/ptsans/v11/jizfRExUiTo99u79B_mh0OOtLR8a8zILig.woff2 wget https://fonts.gstatic.com/s/ptsans/v11/jizfRExUiTo99u79B_mh0OqtLR8a8zILig.woff2 wget https://fonts.gstatic.com/s/ptsans/v11/jizfRExUiTo99u79B_mh0OCtLR8a8zILig.woff2 wget https://fonts.gstatic.com/s/ptsans/v11/jizfRExUiTo99u79B_mh0O6tLR8a8zI.woff2
fonts.googleapis.com and fonts.gstatic.com should not be required after 4c22cb9. I haven't built the new assets though, so just pulling "master" won't be enough to test it. I wonder if we can use native emojis these days... Does anyone have an idea if the major Linux distros ship with emoji support now? And I hope "unsafe-inline" and "unsafe-eval" for "script" is fixed already. |
This can be added. Adding this for the sake of getting it later/tweaking before PR.
Another good doc on potentially getting rid of the unsafe-inline with sha256. https://www.getastra.com/kb/knowledgebase/content-security-policy-all-you-need-to-know/ @jhthorsen as for the emojis, doing |
I think doing somehting like this is more readable and it's also easier to read the diff, in case we need to change one of the parameters.
If possible, please sort the lines. Example: Would be nice if "object-src" could come after "img-src". |
Here is another way to write the code:
|
#508 will get merged one way or another, so I'm closing this issue. |
#508 broke Convos, so I had to revert it. This needs to work with (at least)
I'll try to test it better next time before I make a release. |
Which section broke emojis and embeds of images? |
Should also have a look at https://digi.ninja/blog/svg_xss.php |
Describe the bug
Multiple.
Currently, with CSP, connecting to the server blocks things like inline code and evals. Requiring the flag
usafe-inline
andunsafe-eval
. batman has already started working on removing inline JS.Setting
default-src
(with flags other than outlining the allowed, recommended with nothing else set is 'self') blocks the external calls to gstatic and MaxCDN. Will post another comment outlining the proper use of this header when all is said and done.Please reference https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy for full info on CSP.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Documentation should (in my opinion) enable this correctly by default, but if not, allow users the option to enable it and give them the correct header info to do so.
Environment:
Additional context
Current working header below. Will update with future fixes in the comments of this issue.
add_header Content-Security-Policy "default-src 'self' 'unsafe-inline' 'unsafe-eval' object-src 'none' https;";
The text was updated successfully, but these errors were encountered: