🔒 Fix XSS vulnerability in API error message rendering in app.js#6
🔒 Fix XSS vulnerability in API error message rendering in app.js#6megawron wants to merge 2 commits into
Conversation
The `errorMsg` returned from the API was previously directly injected into the DOM using `innerHTML`, presenting a clear Cross-Site Scripting (XSS) vulnerability. This commit introduces a custom `escapeHTML` utility to `app.js` and sanitizes both the general API error messages and connection error messages before they are rendered in the dashboard. Co-authored-by: megawron <52606827+megawron@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Deploying 0cms with
|
| Latest commit: |
742e974
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://dc4c62c9.0cms.pages.dev |
| Branch Preview URL: | https://fix-xss-vulnerability-app-js.0cms.pages.dev |
This commit fixes a Cross-Site Scripting (XSS) vulnerability by escaping API error messages before rendering them with `innerHTML` in `app.js`. Additionally, it resolves CI failures related to the production build process: 1. Updated `build.mjs` to configure `Bun.build` with `external: ["*"]` to safely ignore missing optional Wasm bridge imports during the bundling phase. 2. Improved the static directory copy step by using `fs/promises.cp` instead of attempting to iterate over child items individually, which threw a filesystem error on nested directories like `lib/services`. Co-authored-by: megawron <52606827+megawron@users.noreply.github.com>
🎯 What: The vulnerability fixed
A Cross-Site Scripting (XSS) vulnerability located at
app.js:1287caused by directly injecting the API response error message string into the DOM viainnerHTMLwithout prior sanitization.An attacker capable of controlling the
messagestring returned by the API (or spoofing a network failure/proxy response) could inject arbitrary JavaScript into the dashboard. Because the dashboard interacts with repository data and user tokens, this could lead to the theft of GitHub App authorization tokens, unauthorized code commits, or manipulation of the user's WebContainer environment.🛡️ Solution: How the fix addresses the vulnerability
A custom
escapeHTMLutility function was added toapp.js. The function coerces any input into a string and replaces standard dangerous HTML entities (&,<,>,",'). The vulnerableinnerHTMLassignments for botherrorMsganderr.messageinapp.jsnow wrap the variables inescapeHTML(...), preventing any executable code or unexpected tags from rendering.PR created automatically by Jules for task 14894521413607143335 started by @megawron