Skip to content

fix(tools): block non-global and malformed addresses in assert_public_url - #1241

Open
1828703450qqcom-ux wants to merge 1 commit into
volcengine:mainfrom
1828703450qqcom-ux:fix/ssrf-non-global-addresses
Open

1828703450qqcom-ux wants to merge 1 commit into
volcengine:mainfrom
1828703450qqcom-ux:fix/ssrf-non-global-addresses

Conversation

@1828703450qqcom-ux

Copy link
Copy Markdown

Problem

assert_public_url() (shared by web_fetch, http_request, vision, image_transform, document_parse, and speech_to_text) only rejected addresses marked is_private, is_loopback, is_link_local, is_reserved, is_multicast, or is_unspecified:

  1. Shared Address Space (100.64.0.0/10, RFC 6598 — including cloud instance metadata endpoints such as 100.96.0.96 and 100.100.100.200) has is_private == False and is_global == False in Python's ipaddress, so requests to those addresses were allowed.
  2. Scoped IPv6 addresses (fe80::1%eth0) or malformed resolver entries hit except ValueError: continue, and an empty socket.getaddrinfo() result returned without failing closed.

Change

  • Require ip.is_global in _assert_public_host(), matching generated_agent_security._validate_target_ip.
  • Strip IPv6 zone suffixes (%scope) before parsing and fail closed when getaddrinfo() returns no addresses or an unparseable address.

Verification

  • Reproduced on origin/main (100.96.0.96, empty getaddrinfo(), 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, and git diff --check passed.

Prepared with AI assistance; reviewed and verified locally.

This branch has not been deployed

No deployments
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.

1 participant