Skip to content
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

Content-Security-Policy: Cannot add script-src directive 'self' #16243

Closed
janis91 opened this issue Jul 5, 2019 · 10 comments
Closed

Content-Security-Policy: Cannot add script-src directive 'self' #16243

janis91 opened this issue Jul 5, 2019 · 10 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug needs info stale Ticket or PR with no recent activity

Comments

@janis91
Copy link

janis91 commented Jul 5, 2019

Steps to reproduce

Developing my app that loads a web worker with ìmportScripts()` to process things in the browser with WebAssembly, I have to add script-src directive 'self', because importScripts does not allow to add nonce in any way. I am currently doing it like this:

                    $cspManager = \OC::$server->getContentSecurityPolicyManager();
                    $csp = new ContentSecurityPolicy();
                    // Allow importScripts(worker.min.js) for Safari
                    $csp->addAllowedScriptDomain("'self'");

Expected behaviour

The script-src should have 'nonce-' AND 'self' in it.

Actual behaviour

The script-src only contains the nonce value.
For everything else (for example if I add 'unsafe-eval' or something else to script-src) it works. Only 'self' is not possible.

Server configuration

PHP version: 7.2

Nextcloud version: 16

Updated from an older Nextcloud/ownCloud or fresh install: fresh install

What is the matter here?

@janis91 janis91 added bug 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Jul 5, 2019
@janis91
Copy link
Author

janis91 commented Jul 12, 2019

Is this intended and if so, why?

@gorn
Copy link

gorn commented Dec 16, 2019

The 'self' predicate is explicitely excluded here which is really strange. I use Nexcloud 17 and just by debuging fresh installed nexcloud in Firefox you see, that even the core javascript files are not loaded (because of CSP). I do not understand reasoning behing this.

@gorn
Copy link

gorn commented Dec 16, 2019

BTW I can confirm this bug, so please @janis91 releave the triage tag.

@kesselb
Copy link
Contributor

kesselb commented Dec 16, 2019

Firefox you see, that even the core javascript files are not loaded (because of CSP). I do not understand reasoning behing this.

This sounds like #17783 and the mentioned firefox bug.

Is this intended and if so, why?

cc @rullzer

@rullzer
Copy link
Member

rullzer commented Dec 16, 2019

It is intented. And it is not a bug. You should add the nonce (which gets added automatically if you do the loadScript stuff) if the browser supports it.

@kesselb
Copy link
Contributor

kesselb commented Apr 27, 2020

Ping @janis91 still an issue?

@janis91
Copy link
Author

janis91 commented May 8, 2020

Well I think it's an issue because otherwise it's impossible to use importScripts for a web worker.

@kesselb kesselb removed the needs info label May 8, 2020
@rullzer
Copy link
Member

rullzer commented May 9, 2020

Well... we don't have any webworkes right now...
Would you mind submitting a basic PR for this? Like a POC then I can see what we can do/would need.

@szaimen
Copy link
Contributor

szaimen commented Jun 2, 2021

Is this Issue still valid? If not, please close this issue. Thanks! :)

@ghost
Copy link

ghost commented Jul 2, 2021

This issue has been automatically marked as stale because it has not had recent activity and seems to be missing some essential information. It will be closed if no further activity occurs. Thank you for your contributions.

@ghost ghost added the stale Ticket or PR with no recent activity label Jul 2, 2021
@ghost ghost closed this as completed Jul 16, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug needs info stale Ticket or PR with no recent activity
Projects
None yet
Development

No branches or pull requests

5 participants