Skip to content

🔒 Fix XSS vulnerability in API error message rendering in app.js#6

Open
megawron wants to merge 2 commits into
mainfrom
fix-xss-vulnerability-app-js-14894521413607143335
Open

🔒 Fix XSS vulnerability in API error message rendering in app.js#6
megawron wants to merge 2 commits into
mainfrom
fix-xss-vulnerability-app-js-14894521413607143335

Conversation

@megawron

Copy link
Copy Markdown
Contributor

🎯 What: The vulnerability fixed
A Cross-Site Scripting (XSS) vulnerability located at app.js:1287 caused by directly injecting the API response error message string into the DOM via innerHTML without prior sanitization.

⚠️ Risk: The potential impact if left unfixed
An attacker capable of controlling the message string 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 escapeHTML utility function was added to app.js. The function coerces any input into a string and replaces standard dangerous HTML entities (&, <, >, ", '). The vulnerable innerHTML assignments for both errorMsg and err.message in app.js now wrap the variables in escapeHTML(...), preventing any executable code or unexpected tags from rendering.


PR created automatically by Jules for task 14894521413607143335 started by @megawron

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>
@google-labs-jules

Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 23, 2026

Copy link
Copy Markdown

Deploying 0cms with  Cloudflare Pages  Cloudflare Pages

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

View logs

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