Skip to content

refactor(security): read legacy numeric hosts with getaddrinfo - #3128

Merged
dan-petty merged 2 commits into
mainfrom
claude/project-thread-0nkhy3-2152
Nov 1, 2026
Merged

dan-petty merged 2 commits into
mainfrom
claude/project-thread-0nkhy3-2152

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Requested by D · project thread

parse_numeric_ip reads an address literal with ipaddress.ip_address, an IPv6 zone ID included. It reads a legacy IPv4 spelling, such as 0177.0.0.1, 127.1 or 2130706433, with socket.getaddrinfo(host, None, flags=socket.AI_NUMERICHOST). The C library reads the host by the rules of the resolver and makes no DNS query. The call catches OSError and UnicodeError, because a long label makes getaddrinfo raise UnicodeEncodeError.

The hand-written parser (_parse_part, _combine_ipv4_parts, _parse_legacy_ipv4) is deleted, and with it the two branches that could not run. The repeated metadata check of the issue was already deleted with validate_url (#2845). The DNS seam of #1314 is still open, so the call goes to socket.getaddrinfo directly.

Spellings that only Python read as numbers (0b11.1, 1_0.0.0.1, +1.2.3.4, Arabic-Indic digits, a trailing space) now give no address, as a resolver reads them as names. 127。0。0。1 now gives 127.0.0.1, as a resolver reads it. is_loopback_or_private_host refuses every one of these hosts before and after.

New tests in tests/core/test_numeric_hosts.py and tests/security/test_reference_address_classes.py pin the octal, three-part and zone-ID forms, the metadata address with a zone ID, and the unparsable-is-private default. The test doubles of getaddrinfo in tests/web_fakes.py and the two reference tests pass a call with AI_NUMERICHOST, which makes no DNS query, and still fail on any other call.

Closes #2152

Change: openspec/changes/archive/2026-11-01-2152-the-egress-checks-read-legacy-numeric/


Generated by Claude Code

…_NUMERICHOST

parse_numeric_ip now reads an address literal with ipaddress, and a
legacy IPv4 spelling such as 0177.0.0.1 or 127.1 with
socket.getaddrinfo and AI_NUMERICHOST. The C library reads the host by
the rules of the resolver and makes no DNS query. The hand-written
parser (_parse_part, _combine_ipv4_parts, _parse_legacy_ipv4) and its
two branches that could not run are deleted.

New tests pin the octal, three-part and zone-ID forms and the
unparsable-is-private default. The test doubles of getaddrinfo now pass
a call with AI_NUMERICHOST, which makes no DNS query.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01PeiMDmFc95FzHYeE9XSjKp
@dan-petty dan-petty self-assigned this Nov 1, 2026
@dan-petty dan-petty changed the title refactor(security): read legacy numeric hosts with getaddrinfo and AI_NUMERICHOST refactor(security): read legacy numeric hosts with getaddrinfo Nov 1, 2026
@dan-petty
dan-petty marked this pull request as ready for review November 1, 2026 23:16
@dan-petty
dan-petty merged commit 41779f9 into main Nov 1, 2026
21 of 22 checks passed
@dan-petty
dan-petty deleted the claude/project-thread-0nkhy3-2152 branch November 1, 2026 23:16
dan-petty-release Bot added a commit that referenced this pull request Nov 1, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.38.0](v0.37.4...v0.38.0)
(2026-11-01)


### Features

* **review:** osv-scanner toolrun records its database digest
([#3120](#3120))
([5731fac](5731fac))
* **roadmap:** add gate tools to the runner, one shell policy
([#3111](#3111))
([7735d8b](7735d8b)),
closes [#3072](#3072)
* **roadmap:** give the step AGENTS.md and routed rules
([#3107](#3107))
([80a22eb](80a22eb)),
closes [#3097](#3097)
* **roadmap:** run the project hooks and scoped CI in the Job
([#3112](#3112))
([b7ab211](b7ab211)),
closes [#3043](#3043)


### Bug Fixes

* **ai:** send the per-call sampling of LLMClient.chat
([#3126](#3126))
([8207bdc](8207bdc))
* **argo:** replace a token that Argo CD refuses
([#3121](#3121))
([b4955b4](b4955b4))
* **devcontainer:** remove CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC
([#3125](#3125))
([295c32c](295c32c))
* **k8s:** set q8_0 KV cache on every Ollama tier
([#3101](#3101))
([aad0115](aad0115))
* **rag:** raise EmbeddingsError for an empty Ollama URL list
([#3118](#3118))
([111a031](111a031))
* **security:** refuse PYTEST_ADDOPTS and npm_config_logs_dir overrides
([#3119](#3119))
([9fe2af5](9fe2af5))


### Code Refactoring

* **security:** read legacy numeric hosts with getaddrinfo
([#3128](#3128))
([41779f9](41779f9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
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.

refactor(security): the egress checks read legacy numeric hosts with getaddrinfo and AI_NUMERICHOST, and the hand-written ipv4 parser goes

2 participants