Repository navigation
Sanitizing untrusted URLs is a common technique for preventing attacks such as request forgeries and malicious redirections. Usually, this is done by checking that the host of a URL is in a set of allowed hosts. - #4154
Closed
wjc2821296948 wants to merge 1 commit into
Closed
wjc2821296948 wants to merge 1 commit into
wjc2821296948 wants to merge 1 commit into
Conversation
… sanitization Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
PR Code Suggestions ✨No code suggestions found for the PR. ⚙️ Agent run details
|
Collaborator
|
Thanks for tightening the host check here. #4143 landed the same exact-host comparison ten minutes after you opened this, and also narrowed |
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.
User description
Use parsed hostname-based validation with exact/normalized comparison instead of substring matching on netloc.
Best fix in this file:
In pr_agent/git_providers/github_provider.py, update the conditions in _parse_pr_url and _parse_issue_url that currently use 'api.github.com' in parsed_url.netloc.
Compare parsed_url.hostname (lowercased) to "api.github.com" exactly.
Keep existing /api/v3 path handling logic unchanged to avoid functionality changes.
This preserves behavior for legitimate GitHub API URLs while removing substring-bypass cases.
PR Type
Bug fix
Description
Replace substring checks with exact hostname comparisons.
Normalize hostnames in PR and issue parsers.
Preserve existing
/api/v3handling.File Walkthrough
github_provider.py
Use exact hostname matching in GitHub URL parserspr_agent/git_providers/github_provider.py
_parse_pr_urland_parse_issue_urlto compare the parsedhostname exactly with
api.github.com.netlocchecks while preserving existing/api/v3handling.
⚙️ Agent run details