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

dsa-webworker can't load scripts if CSP uses nonce #521

Closed
fancycode opened this issue May 4, 2017 · 9 comments
Closed

dsa-webworker can't load scripts if CSP uses nonce #521

fancycode opened this issue May 4, 2017 · 9 comments

Comments

@fancycode
Copy link
Contributor

fancycode commented May 4, 2017

I'm running ojsxc 3.1.1 on Nextcloud 11.0.3 which uses a CSP with a random nonce for loading scripts:

content-security-policy:default-src 'none';script-src 'nonce-T3JrazRtVzhXbzI5djU1Q01uQXR5ZFhFVXFPRlFuNTNUSHBTdk9TaVIyUT06WGRRVTF3cUtITW4vemU0aGZTUkF2NFdpTzlyd0N6d0VIeXRxaTdickl4RT0=' 'unsafe-eval';style-src 'self' 'unsafe-inline' 'unsafe-inline';img-src 'self' data: blob:;font-src 'self';connect-src 'self' wss://10.1.7.145 my-domain ;media-src 'self' blob:;frame-src 'self';child-src 'self'

This causes a problem for the dsa-webworker.js which tries to load external scripts but omits the nonce when doing so:

Refused to load the script 'https://10.1.7.145/apps/ojsxc/js/jsxc/lib/otr/vendor/salsa20.js' because it violates the following Content Security Policy directive: "script-src 'nonce-T3JrazRtVzhXbzI5djU1Q01uQXR5ZFhFVXFPRlFuNTNUSHBTdk9TaVIyUT06WGRRVTF3cUtITW4vemU0aGZTUkF2NFdpTzlyd0N6d0VIeXRxaTdickl4RT0=' 'unsafe-eval'".
dsa-webworker.js:36 Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://10.1.7.145/apps/ojsxc/js/jsxc/lib/otr/vendor/salsa20.js' failed to load.
    at onmessage (https://10.1.7.145/apps/ojsxc/js/jsxc/lib/otr/lib/dsa-webworker.js:36:19)
@sualko
Copy link
Member

sualko commented May 16, 2017

In which app does this happens? Do you use any pipe/combine/minify mechanism? Can you post the complete HTTP header?

@sualko
Copy link
Member

sualko commented Jul 5, 2017

@theCalcaholic can you post the complete header of the html file on which the error occurs?

@theCalcaholic
Copy link

I don't have that error anymore, sorry. It was fixed for me in an update to the jsxc, iirc.

@sualko
Copy link
Member

sualko commented Jul 6, 2017

@theCalcaholic thanks for reporting.

@sualko sualko closed this as completed Jul 6, 2017
@Frakir85
Copy link

hi. Have same trouble with Nextcloud 12.0.3
dsa-webworker.js:36 Refused to load the script 'https://cloud.ipcd.ru/apps/ojsxc/js/jsxc/lib/otr/vendor/salsa20.js' because it violates the following Content Security Policy directive: "script-src 'nonce-eHhNT3F2bXFVNXZYNC9oRHYwWGtHcXhMbXRqbDZJSjVTSzJwWDF6Q08wZz06a1VRNXhZSEhGYXlaMFo5MTB5ZWlTZGtNLzRHM3VzY2dJb2JzQnhXa0Nqbz0=' 'unsafe-eval'".
onmessage @ dsa-webworker.js:36

Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://cloud.ipcd.ru/apps/ojsxc/js/jsxc/lib/otr/vendor/salsa20.js' failed to load.
at onmessage (http://cloud.ipc.lc/apps/ojsxc/js/jsxc/lib/otr/lib/dsa-webworker.js:36:19)
onmessage @ dsa-webworker.js:36
cloud.ipcd.ru-1508796130690.log

@sualko
Copy link
Member

sualko commented Oct 27, 2017

This is a known bug and I already opened an issue nextcloud/server#5936. For me it looks like there is no nice fix for this, so we probably have to concatenate the web worker. Btw. pull requests are always welcome.

@sualko sualko reopened this Oct 27, 2017
@sualko sualko added the bug label Oct 27, 2017
@Frakir85
Copy link

Frakir85 commented Nov 5, 2017 via email

@sualko
Copy link
Member

sualko commented Nov 14, 2017

I played a bit with policy rules in app.php and ended up with adding my domain as additional rule for addAllowedScriptDomain.

Sadly this doesn't work, because Nextcloud replaces the script-src with a nonce 😢

@sualko sualko closed this as completed in 980cd35 Nov 14, 2017
@sualko
Copy link
Member

sualko commented Nov 14, 2017

Hope this fix works for you guys.

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

No branches or pull requests

4 participants