Repository navigation
fix(tools): connect fetch_url to the address that the check saw - #740
Open
omkargaikwad23 wants to merge 4 commits into
Open
omkargaikwad23 wants to merge 4 commits into
omkargaikwad23 wants to merge 4 commits into
Conversation
The fetch_url judge tool checks that the host of a URL does not resolve to a private, loopback, or link-local address. The connection then resolved the host name a second time, so a DNS answer that changed between the two lookups reached an address that the check did not see. The tool now connects through its own function. It resolves the host name one time, refuses a blocked address, and connects to one of the addresses that it checked. TLS still verifies the host name. The tool ignores proxy settings, because a proxy resolves the host name itself.
omkargaikwad23
marked this pull request as ready for review
November 26, 2026 07:50
omkargaikwad23
requested review from
IsmailMehdi,
helloeve and
prernakakkar-google
as code owners
November 26, 2026 07:50
Collaborator
Author
|
/gcbrun |
Text changes only. The docstring of _is_blocked_ip now names each blocked address type. The docstring of _connect says what passed the check. _CheckedHTTPSHandler has a docstring. One sentence in judge_tools.md is reworded.
Keep the notes to what a user of the tool can rely on. The SSRF guard note now also names redirect targets and the connection address. The separate notes for those two are removed.
Collaborator
Author
|
/gcbrun |
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.
What
The
fetch_urljudge tool connects only to an address that it checked.HTTPS_PROXY. A proxy resolves the host name itself, so the address check cannot apply.docs/judge_tools.mdno longer lists the two known follow-ups (redirects, DNS lookup), because both are done. It has a note about the proxy.Why
The tool checked that the host of a URL does not resolve to a private address. The connection then resolved the host name a second time. A DNS answer that changes between the two lookups sent the connection to an address that the check did not see, for example an internal service.
Behavior change: where HTTPS requests need a proxy,
fetch_urlnow fails with a connection error.Testing
tools_fetch_url_test.py: 22 tests pass. Withgemini_tools_test.py: 28 tests pass.pycodestyleis clean.127.0.0.1.mainrefusing to connect to 'rebind.example'mainand on this PR:https://example.com/andhttps://www.google.com/robots.txtreturn the page.https://169.254.169.254/andhttps://localhost/are refused.Logs (Google-internal): https://paste.googleplex.com/6755399437647475