Skip to content

Fix CodeQL XSS vulnerability in GoFish assembler - #12

Merged
Chenglong Wang (Chenglong-MS) merged 1 commit into
mainfrom
fix/codeql-xss-vulnerability
Jun 11, 2026
Merged

Chenglong Wang (Chenglong-MS) merged 1 commit into
mainfrom
fix/codeql-xss-vulnerability

Conversation

@Chenglong-MS

Copy link
Copy Markdown
Contributor

Summary

Fixes CodeQL DOM-based XSS vulnerability (js/xss-through-dom) in the GoFish chart assembler.

Problem

The buildRenderFunction in src/gofish/assemble.ts used innerHTML with unsanitized interpolated values:

  • gfDesc.message (line 111) — user-controlled chart descriptor message
  • err.message (line 214) — error message that could contain attacker-controlled content

CodeQL flags these as XSS vulnerabilities because malicious content could be injected into the DOM.

Fix

Added an escapeHtml() utility function that sanitizes text by escaping HTML special characters (&, <, >, ", '') before interpolation into innerHTML templates.

Testing

  • ✅ TypeScript type-check passes (tsc --noEmit)
  • ✅ All existing tests pass (vitest run)
  • No behavior change for safe strings; only prevents HTML injection for malicious content

The GoFish assembler used innerHTML with unsanitized interpolated values
(gfDesc.message and err.message), which CodeQL flags as a DOM-based XSS
vulnerability (js/xss-through-dom).

Added an escapeHtml utility to sanitize untrusted text before inserting
it into innerHTML templates, preventing potential script injection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Chenglong-MS
Chenglong Wang (Chenglong-MS) merged commit d5e729d into main Jun 11, 2026
5 of 8 checks passed
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