Skip to content

fix(security): remove pre-flight resolve paths for egress - #2845

Merged
dan-petty merged 6 commits into
mainfrom
fix/2437-the-pre-flight-resolve-paths-go
Oct 31, 2026
Merged

dan-petty merged 6 commits into
mainfrom
fix/2437-the-pre-flight-resolve-paths-go

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Description

This pull request completes part 5 of issue #1381.

  • Remove pre-flight DNS and SSRF resolution paths in favor of connect-time egress enforcement.
  • Update kept pre-flight checks (docker engine, config wizard, k8s manifest URL, and qdrant URL) to call vet_addresses.
  • Add transport parameter to new_http_client and new_async_http_client in devops_cli.http.client.
  • Add ast-grep rules and tests to forbid raw HTTP client construction and pre-flight resolve calls.
  • Update documentation and knowledge base to state that HTTP clients enforce egress rules at connect time.

Verification

  • ast-grep test passed with 17 tests.
  • ast-grep scan passed with 0 violations.
  • devops ci fail-to-pass passed (19 failed on base).
  • devops ci fast static checks passed.

Closes #2437

…hecks call vet_addresses, and the docs say every http client is checked at the connect

Remove pre-flight DNS and SSRF resolution paths in favor of connect-time egress enforcement.
Kept pre-flight checks (docker engine, config wizard, k8s manifest URL, and qdrant URL) now call vet_addresses.
Add transport parameter to new_http_client and new_async_http_client.
Add ast-grep rules and tests to prevent raw HTTP client instantiation and pre-flight resolve paths.
Update documentation to clarify connect-time egress checking.

Closes #2437
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault labels Oct 31, 2026
@dan-petty dan-petty changed the title fix(security): the pre-flight resolve paths go, the kept pre-flight checks call vet_addresses, and the docs say every http client is checked at the connect fix(security): remove pre-flight resolve paths for egress Oct 31, 2026
@dan-petty
dan-petty marked this pull request as ready for review October 31, 2026 07:39
…ht-resolve-paths-go

# Conflicts:
#	src/devops_cli/commands/k8s/cluster_context.py
#	tests/ai/client/test_ollama_dynamic_leasing.py
@dan-petty
dan-petty merged commit 6ebc968 into main Oct 31, 2026
19 checks passed
@dan-petty
dan-petty deleted the fix/2437-the-pre-flight-resolve-paths-go branch October 31, 2026 11:51
dan-petty pushed a commit that referenced this pull request Oct 31, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.26.1](v0.26.0...v0.26.1)
(2026-10-31)


### Bug Fixes

* **ci:** allow only declared scopes in pull request titles
([#2846](#2846))
([f6aea38](f6aea38)),
closes [#2800](#2800)
* **security:** remove pre-flight resolve paths for egress
([#2845](#2845))
([6ebc968](6ebc968)),
closes [#2437](#2437)

---
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>
dan-petty added a commit that referenced this pull request Nov 1, 2026
<!-- claude-projects-attribution: {"github_login":"dan-petty"} -->
_Requested by **D** · [project
thread](https://claude.ai/code/project/chan_012AN6yqDPaw2ALcEb3GvKNZ?thread=cmsg_012AN6yqDPaw2ALcEb3GvKNZAsn3P8zcUBU81CBBS6sGhU)_

`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](https://claude.ai/code/session_01PeiMDmFc95FzHYeE9XSjKp)_

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/bug Type bug: the code does not do what it must

Projects

None yet

1 participant