fix: close XSS/HTML-injection CodeQL findings - #1558
Open
doshidhaval wants to merge 1 commit into
Open
Conversation
- sanitizer.ts: stripHtmlComments left a residual "<!--"/"-->" delimiter when leftover prefix/suffix characters recombined after a single-pass block removal (js/incomplete-multi-character-sanitization). Add a defensive pass that strips any surviving delimiter tokens outright. - docs/create-app.html: submitOrgForm() interpolated the untrusted org-name input directly into form.action without encoding (js/xss-through-dom). URL-encode it before building the URL.
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 the two CodeQL error-severity findings currently reported against this repo:
js/incomplete-multi-character-sanitization—stripHtmlComments(src/github/utils/sanitizer.ts) removed full<!--...-->blocks in a single pass. For input like"<!<!---->--> alert(1)", the leftover prefix ("<!") and suffix ("-->") around the removed block recombine into a new"<!-->"delimiter, which survives. A repeated-pass loop doesn't help here since the residual marker has no matching closer for a second pass to find. Fixed by adding a defensive final pass that strips any surviving<!--/-->tokens outright, guaranteeing no delimiter substring can remain.js/xss-through-dom—docs/create-app.html'ssubmitOrgForm()read the org name from an input field and interpolated it directly intoform.actionwithout encoding. Fixed withencodeURIComponent.Test plan
test/sanitizer.test.tscovering the recombination casebun test test/sanitizer.test.ts— 44 pass, 0 failbun run typecheck— cleanprettier --checkon changed files — clean