Skip to content

fix: close XSS/HTML-injection CodeQL findings - #1558

Open
doshidhaval wants to merge 1 commit into
anthropics:mainfrom
doshidhaval:fix/codeql-xss-and-comment-sanitization
Open

fix: close XSS/HTML-injection CodeQL findings#1558
doshidhaval wants to merge 1 commit into
anthropics:mainfrom
doshidhaval:fix/codeql-xss-and-comment-sanitization

Conversation

@doshidhaval

Copy link
Copy Markdown

Summary

Fixes the two CodeQL error-severity findings currently reported against this repo:

js/incomplete-multi-character-sanitizationstripHtmlComments (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-domdocs/create-app.html's submitOrgForm() read the org name from an input field and interpolated it directly into form.action without encoding. Fixed with encodeURIComponent.

Test plan

  • Added a regression test in test/sanitizer.test.ts covering the recombination case
  • bun test test/sanitizer.test.ts — 44 pass, 0 fail
  • bun run typecheck — clean
  • prettier --check on changed files — clean

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