Repository navigation
fix(tools): block non-global and malformed addresses in assert_public_url - #1241
Open
1828703450qqcom-ux wants to merge 1 commit into
Open
1828703450qqcom-ux wants to merge 1 commit into
1828703450qqcom-ux wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Problem
assert_public_url()(shared byweb_fetch,http_request,vision,image_transform,document_parse, andspeech_to_text) only rejected addresses markedis_private,is_loopback,is_link_local,is_reserved,is_multicast, oris_unspecified:100.64.0.0/10, RFC 6598 — including cloud instance metadata endpoints such as100.96.0.96and100.100.100.200) hasis_private == Falseandis_global == Falsein Python'sipaddress, so requests to those addresses were allowed.fe80::1%eth0) or malformed resolver entries hitexcept ValueError: continue, and an emptysocket.getaddrinfo()result returned without failing closed.Change
ip.is_globalin_assert_public_host(), matchinggenerated_agent_security._validate_target_ip.%scope) before parsing and fail closed whengetaddrinfo()returns no addresses or an unparseable address.Verification
origin/main(100.96.0.96, emptygetaddrinfo(), and unparseable address tuples were accepted); all are now rejected.pytest tests/tools/builtin_tools -q: 691 passed, 59 skipped.ruff@0.11.12 check,ruff@0.11.12 format --check, andgit diff --checkpassed.Prepared with AI assistance; reviewed and verified locally.