Potential fix for code scanning alert no. 3: Reflected server-side cross-site scripting#978
Draft
gmorador-tribu wants to merge 2 commits intomainfrom
Draft
Potential fix for code scanning alert no. 3: Reflected server-side cross-site scripting#978gmorador-tribu wants to merge 2 commits intomainfrom
gmorador-tribu wants to merge 2 commits intomainfrom
Conversation
…oss-site scripting Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses code scanning alert #3 (reflected server-side XSS) by ensuring the group query parameter is percent-encoded before being embedded into the client URL fragment generated by goto_url.
Changes:
- Percent-encode the
grouprequest parameter usingurllib.parse.quote(..., safe="")before inserting it into the URL fragment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| group = request.params.get("group", "") | ||
| group = parse.quote(request.params.get("group", ""), safe="") | ||
| query = parse.quote(request.params.get("q", "")) |
There was a problem hiding this comment.
Added three edge case tests in commit c3f146a:
test_it_percent_encodes_group_with_special_characters: verifies a<script>alert("xss")</script>payload is fully encoded and raw<never appears in the output URLstest_it_percent_encodes_group_with_angle_brackets_and_quotes: verifies<"group">→%3C%22group%22%3Etest_it_percent_encodes_group_with_ampersand_and_equals: verifiesgroup&id=1→group%26id%3D1
Agent-Logs-Url: https://github.com/hypothesis/bouncer/sessions/d2cf900c-23c4-485b-a75a-c75e8651ca14 Co-authored-by: gmorador-tribu <204033600+gmorador-tribu@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
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/hypothesis/bouncer/security/code-scanning/3
To fix this without changing behavior, normalize/encode
groupbefore inserting it intofragment, the same wayqis handled. The best minimal fix is to percent-encodegroupusingurllib.parse.quote(..., safe="")when reading it fromrequest.params. This preserves intended semantics (group still passed in fragment) while preventing injection payloads from being reflected as active markup/script.In
bouncer/views.py, insidegoto_url:groupassignment (currently rawrequest.params.get("group", "")) to a quoted value.No new imports are required because
parseis already imported fromurllib.Suggested fixes powered by Copilot Autofix. Review carefully before merging.