Skip to content

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
The-PR-Agent:mainfrom
wjc2821296948:alert-autofix-2

Conversation

@wjc2821296948

@wjc2821296948 wjc2821296948 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

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/v3 handling.


File Walkthrough

Relevant files
Bug fix
github_provider.py
Use exact hostname matching in GitHub URL parsers               

pr_agent/git_providers/github_provider.py

  • Update _parse_pr_url and _parse_issue_url to compare the parsed
    hostname exactly with api.github.com.
  • Lowercase hostnames and default missing hostnames to an empty string.
  • Remove substring-based netloc checks while preserving existing /api/v3
    handling.
+4/-2     


⚙️ Agent run details
  • Model: openai/gpt-6.1-sol
  • Tokens: 4,308 in / 231 out / 4,539 total
  • Time cost: 6.6s
  • AI calls: 1

… sanitization

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@the-pr-agent-bot

Copy link
Copy Markdown

PR Code Suggestions ✨

No code suggestions found for the PR.


⚙️ Agent run details
  • Model: openai/gpt-6.1-sol
  • Tokens: 4,272 in / 74 out / 4,346 total
  • Time cost: 4.1s
  • AI calls: 1

@IsmaelMartinez

Copy link
Copy Markdown
Collaborator

Thanks for tightening the host check here. #4143 landed the same exact-host comparison ten minutes after you opened this, and also narrowed /api/v3 to a path prefix, so main already covers it. Closing as superseded.

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.

2 participants