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

Missing IDN conversion in Content-Security-Policy builder #3086

Closed
Sprinterfreak opened this issue Jul 25, 2023 · 4 comments · Fixed by #3507
Closed

Missing IDN conversion in Content-Security-Policy builder #3086

Sprinterfreak opened this issue Jul 25, 2023 · 4 comments · Fixed by #3507
Labels
1. to develop Waiting for a developer bug Something isn't working good first issue Good for newcomers

Comments

@Sprinterfreak
Copy link

Describe the bug
richdocuments breaks entire nextcloud instance if installed on an instance with unicode domain.
Adds raw unicode domain to the Content-Security-Policy-Header which makes browsers ignore those and therefore prevent any assets from being loaded. Nextcloud without javascript, images and css doesn't look that good.

To Reproduce
Install richdocuments on an instance with idn domain.

Expected behavior
FQDN in the Content-Security-Policy-Header must be idn_ascii converted

See nextcloud/server#39555 for details (including patch)

@kesselb has allready developed a patch for that nextcloud/server#39555 (comment), which I can confirm working.

@Sprinterfreak
Copy link
Author

Still affects richdocuments 8.1.1

@joshtrichards joshtrichards added bug Something isn't working 1. to develop Waiting for a developer labels Nov 10, 2023
@Sprinterfreak
Copy link
Author

Still affects richdocuments 8.2.3 although the responsible code has been rewritten

@juliushaertl
Copy link
Member

Pasting this here for reference:

https://www.php.net/manual/de/function.idn-to-ascii.php

Index: lib/Listener/CSPListener.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/lib/Listener/CSPListener.php b/lib/Listener/CSPListener.php
--- a/lib/Listener/CSPListener.php	(revision 1b609dac1bf216c4913188ab3861f37fabb49147)
+++ b/lib/Listener/CSPListener.php	(date 1690223340061)
@@ -66,6 +66,7 @@
 		);
 
 		$urls = array_filter($urls);
+		$urls = array_map(fn($url) => idn_to_ascii($url), $urls);
 
 		$policy = new EmptyContentSecurityPolicy();
 		$policy->addAllowedFrameDomain("'self'");

@juliushaertl juliushaertl added the good first issue Good for newcomers label Nov 24, 2023
juliushaertl added a commit that referenced this issue Nov 24, 2023
Signed-off-by: Julius Härtl <jus@bitgrid.net>
@juliushaertl
Copy link
Member

Added a commit to #3315

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Waiting for a developer bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants