fix(proxy): add data: to font-src CSP to allow bundled KaTeX fonts#12070
fix(proxy): add data: to font-src CSP to allow bundled KaTeX fonts#12070mmattel merged 3 commits intoowncloud:masterfrom
Conversation
|
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
|
Fixes one issue referenced in OCISDEV-667 |
181230a to
4b3052b
Compare
|
CI errors are unrelated, S3 backend issues... |
LukasHirt
left a comment
There was a problem hiding this comment.
In general I would love to see a fix loading the fonts as actual assets in Web but since inlined fonts are not really a security nono I think this would be a good first step.
Fixing the fonts might involve a bit more work as katex has this really hard coded in the css files so probably some upstream contribution would be required.
I'll restart the CI in the meantime to hopefully get it green.
b0aa884 to
bb0ef32
Compare
bb0ef32 to
b4b5816
Compare
b4b5816 to
494a19e
Compare
|
@paul43210 the CI keeps failing in the same tests. Could you please try to rebase the PR? Maybe that will solve it? |
Head branch was pushed to by a user without write access
494a19e to
2886afc
Compare
|
@LukasHirt Rebased onto latest master as requested. Unfortunately Drone is still failing on the same tests. All tests pass locally — the full As @mmattel noted earlier, the failures appear to be S3 backend infrastructure issues on the Drone side. Let me know if there's anything else I can do to help get this green, or if a maintainer can restart the pipeline. |
|
@paul43210 the S3 failure has been resolved for several past runs. The issue is now in the Core-API-6 tests. It seems that the CSP is actually checked in some test: Failed step: And the following headers should be set
WebDav::theFollowingHeadersShouldBeSet Expected value for header 'Content-Security-Policy' was 'child-src 'self'; connect-src 'self' blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/; default-src 'none'; font-src 'self'; frame-ancestors 'self'; frame-src 'self' blob: https://embed.diagrams.net/; img-src 'self' data: blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/; manifest-src 'self'; media-src 'self'; object-src 'self' blob:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'', but got 'child-src 'self'; connect-src 'self' blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/; default-src 'none'; font-src 'self' data:; frame-ancestors 'self'; frame-src 'self' blob: https://embed.diagrams.net/; img-src 'self' data: blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/; manifest-src 'self'; media-src 'self'; object-src 'self' blob:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'' instead.
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'child-src 'self'; connect-src 'self' blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/; default-src 'none'; font-src 'self'; frame-ancestors 'self'; frame-src 'self' blob: https://embed.diagrams.net/; img-src 'self' data: blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/; manifest-src 'self'; media-src 'self'; object-src 'self' blob:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline''
+'child-src 'self'; connect-src 'self' blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/; default-src 'none'; font-src 'self' data:; frame-ancestors 'self'; frame-src 'self' blob: https://embed.diagrams.net/; img-src 'self' data: blob: https://raw.githubusercontent.com/owncloud/awesome-ocis/; manifest-src 'self'; media-src 'self'; object-src 'self' blob:; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline''This means that the test failure is not a random one and the test needs to be adjusted to expect the new value as well. |
The bundled Web UI CSS (from owncloud/web) inlines the KaTeX_Size3 font as a base64 data:font/woff2 URI. The default CSP sets font-src to 'self' only, which blocks these data URIs and produces a console error on every page load: Loading the font 'data:font/woff2;base64,...' violates the following Content Security Policy directive: "font-src 'self'". Add 'data:' to font-src, matching the existing pattern where img-src already permits data: URIs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2886afc to
d8984c4
Compare
…hange Update acceptance tests and all deployment example CSP configs to include 'data:' in font-src, consistent with the default csp.yaml change. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@LukasHirt Good catch — thanks for digging into the actual test failure. I've pushed a fix in
Core-API-6 should pass now. Let me know if anything else is needed. |
|
fix(proxy): add data: to font-src CSP to allow bundled KaTeX fonts



Problem
The bundled Web UI CSS (
services/web/assets/core/assets/style-*.css, sourced from theowncloud/webrelease tarball) contains an inlined KaTeX math font (KaTeX_Size3) as adata:font/woff2;base64,...URI. This is used by the md-editor component for formula rendering.The default proxy CSP in
services/proxy/pkg/config/csp.yamlsetsfont-src: 'self', which blocksdata:URIs. This causes the following console error on every page load for all oCIS users:Fix
Add
data:to thefont-srcdirective in the default CSP, consistent with howimg-srcalready allowsdata:URIs.Note for users with custom CSP files
This fix updates the embedded default CSP. Users who have set
PROXY_CSP_CONFIG_FILE_LOCATIONto point to a custom CSP YAML file will need to manually add- 'data:'under theirfont-srcdirective, as custom files take precedence over the embedded default.Root cause
The root cause is that the
owncloud/webbuild pipeline inlines the KaTeX font as base64 in the CSS bundle (likely via Vite'sassetsInlineLimit). A complementary fix in theowncloud/webrepository to emit the font as a separate.woff2file instead of inlining it would eliminate the need fordata:infont-srcentirely, but that is out of scope for this PR.