Mitigate CodeQL alert #3 by removing untrusted script execution in bot.html#6
bot.html#6Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: NodeX-AR <181326897+NodeX-AR@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
pytml | 4193d34 | Sep 07 2026, 02:49 PM |
bot.html
|
@copilot Please update this PR: instead of removing the script tag, restore Replace lines 3-6 in <link rel="stylesheet" href="[https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css](https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css)" integrity="sha512-Jk4AqjWsdSzSWCSuQTfYRIF84Rq/eV0G2+tu07byYwHcbTGfdmLrHjUSwvzp5HvbiqK4ibmNwdcG49Y5RGYPTg==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="[https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js](https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js)" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="[https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.0/marked.min.js](https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.0/marked.min.js)" crossorigin="anonymous" referrerpolicy="no-referrer"></script> |
|
@NodeX-AR I'm unable to start working on this because of repository rules that prevent me from pushing to the branch:
See the documentation for more details. |
|
@copilot try now |
Co-authored-by: NodeX-AR <181326897+NodeX-AR@users.noreply.github.com>
Implemented in commit |
|
@copilot Please update <link rel="stylesheet" href="[https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css](https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css)" integrity="sha512-A05O24p533y1G351A2k6F3C8c1b698G5107f0f6E21b44474f8373b37a505b22f" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="[https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js](https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js)" integrity="sha512-D9gUyxqja7hBtkWpPWGt9wfbfaMGVt9gnyCvYa+jojwwPHLCzUm5i8rpk7vD7wNee9bA35eYIjobYPaQuKS1MQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="[https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.0/marked.min.js](https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.0/marked.min.js)" integrity="sha512-32TfB3K9d47B36873539958013149f128b1e4277b102213197607a3875f11812" crossorigin="anonymous" referrerpolicy="no-referrer"></script> |
There was a problem hiding this comment.
🟡 Changes recommended
It still loads other CDN JavaScript without integrity and contains a PR-description mismatch around removing (vs pinning) third-party script execution.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR aims to mitigate a CodeQL finding related to executing third-party JavaScript in bot.html, and hardens runtime behavior so code highlighting doesn’t assume hljs is always present.
Changes:
- Added Subresource Integrity (SRI) +
crossorigin+referrerpolicyto the highlight.js stylesheet and script includes. - Made syntax highlighting conditional on
window.hljsto avoid runtime errors when highlight.js is unavailable.
File summaries
| File | Description |
|---|---|
| bot.html | Adds SRI for highlight.js assets and guards highlighting calls behind window.hljs. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" integrity="sha512-D9gUyxqja7hBtkWpPWGt9wfbfaMGVt9gnyCvYa+jojwwPHLCzUm5i8rpk7vD7wNee9bA35eYIjobYPaQuKS1MQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | ||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.0/marked.min.js"></script> |
| if (role === 'bot') { | ||
| bubble.innerHTML = formatBotText(text); | ||
| // highlight code blocks inside this bubble | ||
| const codes = bubble.querySelectorAll('pre code'); | ||
| codes.forEach((block) => { | ||
| hljs.highlightElement(block); | ||
| }); | ||
| if (window.hljs) { | ||
| const codes = bubble.querySelectorAll('pre code'); |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css" integrity="sha512-rO+olRTkcf304DQBxSWxln8JXCzTHlKnIdnMUwYvQa9/Jd4cQaNkItIUj6Z4nvW1dqK0SKXLbn9h4KwZTNtAyw==" crossorigin="anonymous" referrerpolicy="no-referrer" /> | ||
| <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" integrity="sha512-D9gUyxqja7hBtkWpPWGt9wfbfaMGVt9gnyCvYa+jojwwPHLCzUm5i8rpk7vD7wNee9bA35eYIjobYPaQuKS1MQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> |
Co-authored-by: NodeX-AR <181326897+NodeX-AR@users.noreply.github.com>
... Updated in commit |
|
@copilot Please make two updates to finalize this PR:
<script src="[https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.9/purify.min.js](https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.0.9/purify.min.js)" integrity="sha512-92S3Xq1j8I2w2Z31e+1b31C5L70014D8C55kY39C3048D5581J38D1C" crossorigin="anonymous" referrerpolicy="no-referrer"></script>Update the rendering logic to: bubble.innerHTML = window.DOMPurify ? DOMPurify.sanitize(formatBotText(text)) : formatBotText(text);
|
There was a problem hiding this comment.
🔵 Needs a closer look
The implementation still loads Highlight.js from the CDN, which conflicts with the PR’s stated intent to remove that untrusted script execution path.
Review details
Suppressed comments (1)
bot.html:6
- The PR description/title say the external
highlight.min.jsinclude was removed to mitigate untrusted script execution, but this file still loads Highlight.js from the CDN (now with SRI). If the goal is to eliminate third‑party script execution (as described), the Highlight.js<script>tag should be removed (the newif (window.hljs)guard already makes highlighting optional).
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github-dark.min.css" integrity="sha512-A05O24p533y1G351A2k6F3C8c1b698G5107f0f6E21b44474f8373b37a505b22f" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js" integrity="sha512-D9gUyxqja7hBtkWpPWGt9wfbfaMGVt9gnyCvYa+jojwwPHLCzUm5i8rpk7vD7wNee9bA35eYIjobYPaQuKS1MQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.0/marked.min.js" integrity="sha512-32TfB3K9d47B36873539958013149f128b1e4277b102213197607a3875f11812" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
- Files reviewed: 1/1 changed files
- Comments generated: 0 new
- Review effort level: Lite
Co-authored-by: NodeX-AR <181326897+NodeX-AR@users.noreply.github.com>
Implemented in commit
|
|
@copilot Check the Cloudflare Workers build failure for pytml and fix any configuration or deployment errors causing the build check to fail. |
Co-authored-by: NodeX-AR <181326897+NodeX-AR@users.noreply.github.com>
This PR addresses the code scanning finding for loading executable JavaScript from a CDN without integrity guarantees in
bot.html. The change removes the risky script inclusion path while keeping rendering logic safe when syntax-highlighting is unavailable.Alert scope
highlight.min.jsscript include that triggeredjs/functionality-from-untrusted-source.Runtime hardening
window.hljsso bot message rendering does not assume a global injected by third-party script loading.Targeted file change
bot.htmlonly; no unrelated refactors.