Fix CodeQL XSS vulnerability in GoFish assembler - #12
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes CodeQL DOM-based XSS vulnerability (js/xss-through-dom) in the GoFish chart assembler.
Problem
The
buildRenderFunctioninsrc/gofish/assemble.tsusedinnerHTMLwith unsanitized interpolated values:gfDesc.message(line 111) — user-controlled chart descriptor messageerr.message(line 214) — error message that could contain attacker-controlled contentCodeQL 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
tsc --noEmit)vitest run)