Repository navigation
fix: build the policy sentence from text nodes, not markup - #30
Merged
Merged
Conversation
The website's policy picker pasted the policy name it read from the page into innerHTML, which CodeQL flags as DOM text reinterpreted as HTML. The sentence is now built from text nodes, so any name shows as text, and the documentation search escapes quotes in the result links it writes.
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.
Fixes the CodeQL alert js/xss-through-dom #1 in
docs/assets/site.js.What was wrong
The policy picker on the website reads the policy name from the clicked button's
data-policyattribute and pasted it intosummary.innerHTML. The three values in our HTML are fixed, so nothing could exploit it today, but any markup in that attribute would have run: with the code onmain, settingdata-policyto<img src=x onerror=…>and clicking runs the handler.The fix
orthology_evidence.tsvgo into<code>elements withtextContent, and the count into<b>. The same injected attribute now shows as literal text and runs nothing.escapeHtmlin the documentation search also escapes", and the result links pass theirhrefthrough it, so the one attribute the search writes cannot be broken out of either.Checked
mainand not on this branch.guide/outputs.html) still gives correct../links with highlighting, and the first one opens.check_site.py --run-tutorialand the auto-merge gate check all pass.CodeQL closes the alert on its own once this reaches
main.