Skip to content

fix(security): move the remaining HTTP clients onto the egress-checked factory and delete the pre-flight resolve paths #1381

Closed as not planned
5 of 5 issues completed

Description

@dan-petty

Problem

#898 ("PR A") added the connect-time egress check: devops_cli.http.egress (EgressLevel, vet_addresses/avet_addresses, VettingBackend/AsyncVettingBackend) and the factory in devops_cli.http.client. It moved the broker, the shared pool, web_fetch, Jaeger, the sandbox probe, tool downloads and the existing factory callers onto them. Every other client still builds a raw httpx2.Client / httpx2.AsyncClient or calls httpx2.get/post. Those clients check a hostname before the dial (some check nothing) and let httpx2 resolve it again at the socket, which is the rebinding window #898 closed for the moved callers.

Scope (the PR B part of #898's body, now its own issue)

Acceptance criteria

  • rg -n -g '*.py' '_resolve_host_ips|_enforce_non_private_ssrf' src prints nothing.
  • rg -n -g '*.py' 'httpx2\.((Async)?Client|get|post|put|patch|delete|head|request|stream)\(' src lists only src/devops_cli/http/client.py, plus github/client.py until refactor(github): the github session owns transport, ledger, error classes and link pagination #983 lands.
  • The level-table test in tests/test_http_egress.py (test_each_caller_dials_at_its_level) covers every moved caller, with and without ai.allow_private_network. Each narrower or wider row has a case that fails on the code before the move.
  • Address pre-flight checks remain only at the callers listed above.
  • The review guidance and docs say every HTTP client is checked at the connect only once that is true.
  • Tests stay offline (ScriptedResolver and ConnectRecorder in tests/web_fakes.py), each call phase stays under 1 s, and uv run devops ci passes.

Context

Split from #898: readiness requires a PR to close exactly one issue, and #898's task file reads Done in the PR A commit. Depends on #898. Related: #1001 (AI clients take a factory client but stay off the broker), #1112, #983, #1108, #1113, #887.


Split from #898 on 2026-10-08 (borrow reason: split). Filed directly with no priority; the roadmap service's intake sets Priority, Value and Effort.

Update 2026-10-08: refinement

github/graphql.py is gone; the raw GitHub clients move with #983, and #1331 deletes the legacy providers' clients. #1001 rebuilds create_pydantic_ai_provider on the factory. #1319 moves the tracer clients.

Proposed design

Problem statement

The remaining HTTP clients in devops-cli build raw httpx2 connections that check a hostname before the dial. httpx2 then resolves the name again at the socket, which opens a DNS rebinding window. This issue moves every such client to the egress-checked factory so the address is checked at the connect. It also deletes the pre-flight resolve functions and updates the documentation to state that every client is checked at the connect.

Acceptance criteria

  • Criterion 1: The pre-flight resolve functions are deleted from the codebase.
    Verification: Run rg -n -g '*.py' '_resolve_host_ips|_enforce_non_private_ssrf' src and confirm it prints nothing.
  • Criterion 2: Only the factory and the deferred callers build raw httpx2 connections.
    Verification: Run rg -n -g '*.py' 'httpx2\.((Async)?Client|get|post|put|patch|delete|head|request|stream)\(' src and confirm the output lists only src/devops_cli/http/client.py, plus github/ until refactor(github): the github session owns transport, ledger, error classes and link pagination #983 lands and the legacy providers until test(ai): the remaining ai modules are tested through their public interfaces on edge fakes, and the legacy provider layer leaves src #1331 lands.
  • Criterion 3: The level-table test covers every moved caller with a failing case on the pre-move code.
    Verification: Run uv run pytest tests/test_http_egress.py -k test_each_caller_dials_at_its_level -v and confirm each moved caller has a row, with and without ai.allow_private_network, and each narrower or wider row fails on the code before the move.
  • Criterion 4: Address pre-flight checks remain only at the callers listed in the issue body.
    Verification: Run rg -n 'vet_addresses' src and confirm the results are limited to the callers that fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898's pre-flight key question names (qdrant-client, k8s apply, container engine, Valkey GLIDE, PlaywrightBrowser stub, sandbox CIDR builders, config wizard) plus k8s/service_http.py.
  • Criterion 5: The review guidance and project docs state that every HTTP client is checked at the connect.
    Verification: Read AGENTS.md, .devops/review.md, README.md, docs/ROUTINE_TASKS.md, the knowledge base libraries/httpx2.md, and the HALLUCINATION-INTERNAL-SERVICE-PRIVATE-NETWORK catalog entry. Confirm each one says every HTTP client is checked at the connect and no longer names only the factory-built clients.
  • Criterion 6: Tests run offline and the full CI suite passes.
    Verification: Run uv run devops ci and confirm it passes. Confirm tests use ScriptedResolver and ConnectRecorder from tests/web_fakes.py and each call phase stays under 1 second.

Key questions

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#1331, #1319, #1317, #1329, #1314

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. added
    type/security
    scope/ai
    scope/security
    source/agent
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Closed as a duplicate of #898: The candidate is explicitly the 'PR B part of #898's body, now its own issue,' and #898's scope already includes 'PR B moves the remaining clients and deletes the old resolve paths.'

    If it is not a duplicate, reopen it: intake then places it without the duplicate check.

  3. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Reopening. #1382 closed #898 with "PR A" only, and its body moves the remaining clients, the pre-flight deletions, the docs crawler and github/client.py here. Intake then closed this issue as a duplicate of #898, so nothing tracks the move any more.

    These sites still build raw clients outside the egress-checked factory at release/v0.2.29 (05e9388).

    AI and data services (15 sites):

    • ai/rag/embeddings.py:380, :629, :659, :796
    • ai/gateway.py:250, :384, :591
    • commands/ai_gateway.py:174
    • ai/pool_load.py:49
    • ai/spend/pricing.py:463, :472
    • ai/library/docs_ingester.py:247
    • security/vulnerability_lookup.py:185, :307, :377

    Dead code that #1005 or #1331 deletes: ai/providers/anthropic.py:77, ai/providers/openai.py:62, ai/providers/ollama.py:37, :65.

    pydantic-ai providers. create_pydantic_ai_provider builds them without http_client (ai/providers/__init__.py:104-110, reached from ai/pydantic_ai_bridge.py:136-142), so they use pydantic-ai's own client. If that path survives #1005, they need http_client=new_async_http_client(level=configured_level(...)).

    GitHub (two bare httpx2.Client calls to api.github.com):

    • the PR diff, GitHubClient.get_pr_diff (github/client.py:131-148, client at :140), which also follows a redirect by hand (:142-146); the factory checks each redirect hop at the connect;
    • the signing-key registration, _add_signing_key (github/ssh.py:148-163, client at :150).

    The infrastructure sites follow in a separate comment.

    Found by the 2026-10-08 client-library audit.

  4. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Raw httpx2 clients in the infrastructure, observability and security slice, checked at 05e9388 (release/v0.2.29). Each one dials outside the egress factory.

    • Telemetry:
      • telemetry/tracer.py:1213, the OTLP export client (_get_http_client);
      • telemetry/tracer.py:1180, the collector probe;
      • plus a raw socket probe at :1143.
    • Prometheus:
      • commands/prometheus.py:144, :198, :280, :334, :376;
      • argo/rollouts.py:92, the rollout metric-gate query.
    • Loki: k8s/logql.py:365 (module-level httpx2.get).
    • Grafana:
      • commands/grafana.py:106, :158, :219, :334, :452, :492, :529;
      • k8s/credentials.py:315 (service-account token mint) and :434 (token check).
    • Argo CD:
      • commands/argo.py:203, :256, :285;
      • argo/fleet.py:59;
      • argo/gitops.py:369;
      • k8s/credentials.py:222 (session) and :403 (token check).
    • Sandbox scrape: sandbox/metrics.py:433. sandbox/probe.py already uses the factory (:124, :291); test(infra): infrastructure tests run on edge fakes #1335's :197/:346 citation predates that.
    • Cloudflare: cloudflare/client.py:286.
    • Also in this slice: security/vulnerability_lookup.py:185, :307, :377 (OSV, InternetDB, Radar).

    Items from the same audit touch several of these clients: the tracer (OTel SDK), Loki (LogQL sent unchanged), Argo CD (sync body), Cloudflare (pagination and retry) and the sandbox scrape (prometheus-client). Whichever lands second moves its client onto the factory.

    Found by the 2026-10-08 client-library audit.

  5. dan-petty commented on Oct 8, 2026

    @dan-petty
    OwnerAuthor

    Linked: #1317 and #1329 move the embedding clients in this inventory, and #1314 builds the seam on the same factory; whichever lands second builds on the other. Found by the 2026-10-08 backlog review.

  6. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P1-High. A known SSRF/rebinding gap remains open for many production HTTP clients, and the fix is already scoped and partially landed via #898.
    • Value: High. Every unmigrated client is exposed to DNS-rebinding SSRF, so closing the gap protects all users who rely on the egress policy.
    • Effort: High. The scope spans dozens of call sites across many modules, requires deleting legacy helpers, updating six+ docs, adding per-caller level tests, and coordinating with at least three other issues.
  7. 4 remaining items

  8. dan-petty commented on Oct 27, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at 15bd601 (see proposed design in issue body).

  9. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    The owner approved the split of this issue into five parts on 2026-10-28. Each part is a sub-issue of this issue:

    No pull request closes this issue. This issue closes when all five parts close.

    Changes to the scope above, checked on origin/main d739a47:

  10. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Closed as not planned: five newer issues supersede this issue (AGENTS.md rule 2). The owner approved the split on 2026-10-28, because the remaining scope was about 68 files in six separate areas, too large for one pull request.

    The newer issues hold all of the work of this issue:

    This replaces the earlier comment that said this issue closes when all five close. The sub-issue links stay for the history.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    scope/aiscope/securitysource/agenttype/security

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions