Skip to content

Conversation

@xihale
Copy link
Member

@xihale xihale commented Jan 25, 2026

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @xihale, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a CDN redirect failure by implementing a more flexible security policy. It removes strict integrity and crossorigin attributes from CDN-hosted resources like KaTeX and Mermaid, which can interfere with CDN redirects. Concurrently, a Content Security Policy (CSP) has been added to the base template, providing a controlled environment by whitelisting trusted sources for various content types, thus mitigating potential security risks while ensuring external resources load correctly.

Highlights

  • CDN Link Security Attributes Removed: The integrity and crossorigin attributes have been removed from CDN-hosted KaTeX and Mermaid script and stylesheet links in content/post/2025-07-19-zine-migration.smd and layouts/post.shtml. This change aims to resolve issues with CDN redirect failures that can occur when these strict security attributes are present.
  • Content Security Policy (CSP) Implemented: A new Content-Security-Policy meta tag has been added to layouts/templates/base.shtml. This policy explicitly whitelists trusted domains for scripts, styles, images, and connection requests, providing a robust security layer while ensuring necessary external resources can be loaded.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@xihale xihale merged commit 3e9a46f into zigcc:main Jan 25, 2026
3 checks passed
@xihale xihale deleted the fix-cdn branch January 25, 2026 03:07
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request aims to resolve a CDN redirect failure by removing Subresource Integrity (SRI) checks and introducing a Content Security Policy (CSP). However, these changes significantly degrade the site's security posture, making it vulnerable to supply chain attacks and Cross-Site Scripting (XSS). The removal of SRI exposes users to potential script injection if the CDN is compromised, and the new CSP is overly permissive due to the use of 'unsafe-inline' and 'unsafe-eval', which negates its protective capabilities. It is strongly recommended to find solutions that maintain SRI (e.g., stable URLs or self-hosting) and to tighten the CSP by avoiding 'unsafe-inline' and 'unsafe-eval' through nonces or hashes.

Comment on lines +21 to 25
<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>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

As with the other resources, removing Subresource Integrity (SRI) for the KaTeX and Mermaid scripts is a security risk. It makes your site vulnerable to attacks originating from a compromised CDN. It is highly advisable to restore SRI protection, perhaps by self-hosting these dependencies.

Comment on lines 173 to 183
href="https://cdnjs.webstatic.cn/ajax/libs/KaTeX/0.16.9/katex.min.css"
integrity="sha512-fHwaWebuwA7NSF5Qg/af4UeDx9XqUpYpOGgubo3yWu+b2IQR4UeQwbb42Ti7gVAjNtVoI/I9TEoYeu9omwcC6g=="
crossorigin="anonymous"
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
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="renderMathInElement(document.body);"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The integrity and crossorigin attributes 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.

<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;">

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-medium medium

The newly added Content Security Policy (CSP) is overly permissive, significantly reducing its effectiveness against Cross-Site Scripting (XSS) attacks. The use of 'unsafe-inline' and 'unsafe-eval' in script-src allows arbitrary inline scripts and dangerous functions, posing major security risks. Additionally, the img-src directive using https: is too broad, allowing images from any HTTPS domain, which could be abused. Whitelisting entire CDN domains like cdnjs.cloudflare.com is also a known risk.
Recommendations:

  1. Remove 'unsafe-inline': Refactor inline scripts or use CSP nonces/hashes.
  2. Remove 'unsafe-eval': Investigate library configurations that don't rely on eval().
  3. Tighten img-src: Replace https: with a whitelist of specific domains.
    It is recommended to use nonces or hashes for legitimate inline scripts and to be more restrictive with allowed sources to strengthen this policy.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant