Potential fix for code scanning alert no. 7: DOM text reinterpreted as HTML#29
Draft
digreatbrian wants to merge 1 commit intomainfrom
Draft
Potential fix for code scanning alert no. 7: DOM text reinterpreted as HTML#29digreatbrian wants to merge 1 commit intomainfrom
digreatbrian wants to merge 1 commit intomainfrom
Conversation
…s HTML Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@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.
Potential fix for https://github.com/duckframework/duck/security/code-scanning/7
In general, the fix is to ensure that the value taken from the DOM (
this.value/version.url) is validated or constrained before it is used to changewindow.location.href. Rather than blindly trusting whatever URL is in the<option>’svalue, we should only allow safe, expected URLs—for example, relative paths within the same site, or absolute URLs withhttp:orhttps:schemes and (optionally) a matching host.The best minimal fix, without changing the user-facing functionality, is to validate
this.valueinside thechangeevent handler and only navigate if it is a safe HTTP(S) URL or a relative URL. We can do this by:URLobject withnew URL(this.value, window.location.origin)to normalize relative paths against the current origin.url.protocolishttp:orhttps:(rejectingjavascript:,data:,vbscript:, etc.).window.location.href = safeUrl.toString().All changes are confined to docs/source/_static/js/version-picker.js, in the
dropdown.addEventListener("change", ...)block around line 58–60. No additional imports are necessary becauseURLis part of the standard Web API.Suggested fixes powered by Copilot Autofix. Review carefully before merging.