-
Notifications
You must be signed in to change notification settings - Fork 17
fix: resolve CDN redirect failure by using loose security policy and CSP whitelist #96
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,10 @@ | ||
| <extend template="base.shtml"> | ||
| <head id="head"> | ||
| <ctx :if="$page.custom.getOr('math', false)"> | ||
| <link href="https://cdnjs.webstatic.cn/ajax/libs/KaTeX/0.16.9/katex.min.css" integrity="sha512-fHwaWebuwA7NSF5Qg/af4UeDx9XqUpYpOGgubo3yWu+b2IQR4UeQwbb42Ti7gVAjNtVoI/I9TEoYeu9omwcC6g==" crossorigin="anonymous" rel="stylesheet"> | ||
| <link href="https://cdnjs.webstatic.cn/ajax/libs/KaTeX/0.16.9/katex.min.css" rel="stylesheet"> | ||
| <script | ||
| defer | ||
| src="https://cdnjs.webstatic.cn/ajax/libs/KaTeX/0.16.9/katex.min.js" | ||
| integrity="sha512-LQNxIMR5rXv7o+b1l8+N1EZMfhG7iFZ9HhnbJkTp4zjNr5Wvst75AqUeFDxeRUa7l5vEDyUiAip//r+EFLLCyA==" | ||
| crossorigin="anonymous" | ||
| ></script> | ||
| <script> | ||
| function renderKaTeX() { | ||
|
|
@@ -20,10 +18,10 @@ | |
| }); | ||
| } | ||
| </script> | ||
| <script defer src="https://cdnjs.webstatic.cn/ajax/libs/KaTeX/0.16.9/contrib/auto-render.min.js" integrity="sha512-iWiuBS5nt6r60fCz26Nd0Zqe0nbk1ZTIQbl3Kv7kYsX+yKMUFHzjaH2+AnM6vp2Xs+gNmaBAVWJjSmuPw76Efg==" crossorigin="anonymous" onload="renderKaTeX()"></script> | ||
| <script defer src="https://cdnjs.webstatic.cn/ajax/libs/KaTeX/0.16.9/contrib/auto-render.min.js" onload="renderKaTeX()"></script> | ||
| </ctx> | ||
| <ctx :if="$page.custom.getOr('mermaid', false)"> | ||
| <script defer src="https://cdnjs.webstatic.cn/ajax/libs/mermaid/11.12.0/mermaid.min.js" integrity="sha512-5TKaYvhenABhlGIKSxAWLFJBZCSQw7HTV7aL1dJcBokM/+3PNtfgJFlv8E6Us/B1VMlQ4u8sPzjudL9TEQ06ww==" crossorigin="anonymous" onload="mermaid.initialize({theme: window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'default'}); mermaid.run();"></script> | ||
| <script defer src="https://cdnjs.webstatic.cn/ajax/libs/mermaid/11.12.0/mermaid.min.js" onload="mermaid.initialize({theme: window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'default'}); mermaid.run();"></script> | ||
| </ctx> | ||
|
Comment on lines
+21
to
25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| </head> | ||
| <body id="body"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| <head id="head"> | ||
| <meta charset="utf-8"> | ||
| <meta name="viewport" content="initial-scale=1"> | ||
| <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline' 'unsafe-eval' https://cdnjs.webstatic.cn https://cdnjs.cloudflare.com https://hm.baidu.com; style-src 'self' 'unsafe-inline' https://cdnjs.webstatic.cn https://cdnjs.cloudflare.com; img-src 'self' data: https:; connect-src 'self' https://en.liujiacai.net https://cdnjs.cloudflare.com https://hm.baidu.com;"> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The newly added Content Security Policy (CSP) is overly permissive, significantly reducing its effectiveness against Cross-Site Scripting (XSS) attacks. The use of
|
||
| <meta name="algolia-site-verification" content="12324D77A7D77468"> | ||
| <title :text="$page.title"></title> | ||
| <link type="text/css" rel="stylesheet" href="$site.asset('style.css').link()"> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
integrityandcrossoriginattributes were removed from the KaTeX resources, disabling Subresource Integrity (SRI). This exposes the site to supply chain attacks if the CDN is compromised, especially given the very loose Content Security Policy (CSP) also implemented. SRI is a crucial security feature that verifies resources from third-party servers haven't been tampered with. If redirects are causing SRI failures, consider using a more stable CDN provider or hosting the assets locally instead of disabling this security control.