Skip to content

fix(tools): apply the fetch_url checks to redirect targets - #728

Merged
omkargaikwad23 merged 4 commits into
mainfrom
fix/fetch-url-validate-redirects
Nov 20, 2026
Merged

omkargaikwad23 merged 4 commits into
mainfrom
fix/fetch-url-validate-redirects

Conversation

@omkargaikwad23

Copy link
Copy Markdown
Collaborator

What this fixes

The fetch_url judge tool checks the URL before the request: HTTPS only, and no private, loopback, or link-local host. It did not check redirect targets. A server could answer with a redirect to a URL that these checks refuse.

How

  • Move the checks into _url_error.
  • Open the request with a redirect handler that applies _url_error to each redirect target. A refused redirect stops the request, and fetch_url returns an error string.

Not in this PR

The host check and the connection still resolve the host name separately, so a change of the DNS answer between the two is not covered.

Testing

  • New tests in tools_fetch_url_test.py for the redirect handler. One test runs the real opener against a local server and confirms that the second request is not sent.
  • pytest evalbench/test with SKIP_CLOUD_TESTS=true: 1269 passed, 11 skipped.

fetch_url checked only the first URL. A redirect could then send the request to a private host or to a URL that is not HTTPS. Check each redirect target with the same rules.
@omkargaikwad23

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@omkargaikwad23

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@omkargaikwad23
omkargaikwad23 merged commit 6ca77dc into main Nov 20, 2026
13 checks passed
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