Skip to content

fix(security): the osv, internetdb, radar and cloudflare api clients dial through the egress-checked factory at the public level #2430

Closed

Description

@dan-petty

Problem Description

Part 3 of #1381. The owner approved the split of #1381 into five parts on 2026-10-28.

The clients of four fixed public APIs build a raw httpx2.Client: OSV, Shodan InternetDB, Cloudflare Radar and the Cloudflare API. They make no address check. httpx2 resolves the API host name at the socket and dials each answer. A bad or rebinding DNS answer for api.osv.dev can thus send the request, and the Cloudflare API token, to a loopback, private or link-local address. #898 closed this gap for the callers that it moved to the egress-checked factory (devops_cli.http.client). This part moves these four clients to the factory at the public level.

Scope, with lines on origin/main d739a47 and the level from the #898 level table:

Caller Raw client Pre-flight check that goes Level
OSV (api.osv.dev), OSVClient security/vulnerability_lookup.py:212 none today public; the flag does not widen it (narrower)
Shodan InternetDB (internetdb.shodan.io), ShodanInternetDBClient security/vulnerability_lookup.py:366 none today public; the flag does not widen it (narrower)
Cloudflare Radar (api.cloudflare.com), CloudflareRadarClient security/vulnerability_lookup.py:475, :477 none today public; the flag does not widen it (narrower)
Cloudflare API (api.cloudflare.com), CloudflareClient._request cloudflare/client.py:366 none today public; the flag does not widen it (narrower)

"The flag" is ai.allow_private_network. "Narrower" means that the client refuses an address that it dials today.

Notes:

  • CloudflareRadarClient.__init__ takes a transport argument (security/vulnerability_lookup.py:466) and builds a raw client around it (:475). No caller in src or tests gives that argument on d739a47. The factory takes no transport, so the argument goes.
  • Keep the timeouts: a 1 s connect timeout for the three lookup clients, and request_timeout(read=30.0) for the Cloudflare API.
  • classify_network_target in ShodanInternetDBClient.check_ip (security/vulnerability_lookup.py:374) decides which addresses the client asks about. It does not check the address that the client dials, so it stays.
  • The callers of these clients do not change: ai/review/pipeline.py:2974, :2975, ai/tools/builtin_tools.py:487, :521, :537, security/dependency_remediator.py:214 and commands/cloudflare.py:64.

Out of scope: the GitHub clients, which #983 moved.

Reproduction Steps

  1. On origin/main (d739a47), run rg -n -g '*.py' 'httpx2\.((Async)?Client|get|post)\(' src/devops_cli/security/vulnerability_lookup.py src/devops_cli/cloudflare/client.py.
  2. In a test, install scripted_resolver(monkeypatch, {"api.osv.dev": [["10.0.0.1"]]}) and record_connects(monkeypatch, []) from tests/web_fakes.py.
  3. Without ai.allow_private_network, call OSVClient().query_package("requests", version="2.0.0", ecosystem="PyPI").
  4. Read recorder.dialled.

Expected vs Actual Behavior

Expected: each client resolves its API host once, at the connect. It dials only public addresses, with or without the flag. A non-public answer gives SSRFBlockedError before the dial. The factory checks each redirect hop the same way.

Actual: step 1 lists the raw clients in the table. In step 4, the client dials 10.0.0.1 on port 443.

Environment Diagnostics

  • DevOps CLI Version: 0.8.3 (origin/main d739a47)
  • Python Version: 3.14.10
  • OS & Architecture: Linux x86_64
  • Execution Environment: DevContainer

Logs, Traces, or Terminal Output

src/devops_cli/cloudflare/client.py:366:            with httpx2.Client(timeout=timeout) as client:
src/devops_cli/security/vulnerability_lookup.py:212:        self._client = httpx2.Client(timeout=httpx2.Timeout(self.timeout, connect=1.0))
src/devops_cli/security/vulnerability_lookup.py:366:        self._client = httpx2.Client(timeout=httpx2.Timeout(self.timeout, connect=1.0))
src/devops_cli/security/vulnerability_lookup.py:475:            self._client = httpx2.Client(transport=transport, timeout=timeout_spec)
src/devops_cli/security/vulnerability_lookup.py:477:            self._client = httpx2.Client(timeout=timeout_spec)

Acceptance criteria

These are the criteria of #1381 that apply to this part.

  • rg -n -g '*.py' 'httpx2\.((Async)?Client|get|post|put|patch|delete|head|request|stream)\(' src/devops_cli/security/vulnerability_lookup.py src/devops_cli/cloudflare/client.py prints nothing.
  • Each client in the table comes from new_http_client(level=EgressLevel.PUBLIC, ...). ai.allow_private_network does not change its level.
  • CloudflareRadarClient takes no transport argument.
  • test_each_caller_dials_at_its_level in tests/test_http_egress.py has a row for each caller in the table, with and without ai.allow_private_network. The test resolves the API host names (api.osv.dev, internetdb.shodan.io, api.cloudflare.com). Each row fails on the code before the move.
  • Tests stay offline (ScriptedResolver and ConnectRecorder in tests/web_fakes.py), and each call phase stays under 1 s.
  • If the move makes a document wrong, the same pull request fixes it. The general statement that every HTTP client is checked at the connect waits for Part 5.
  • The required CI checks pass.

Related

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: #1381

Proposed design

Problem statement

Four public API clients build raw httpx2.Client instances with no address check. A bad or rebinding DNS answer for their API host can send the request, and the Cloudflare API token, to a loopback, private, or link-local address. This issue moves the OSV, Shodan InternetDB, Cloudflare Radar, and Cloudflare API clients to the egress-checked factory at the public level.

Acceptance criteria

  • Criterion 1: No raw httpx2 client or request call remains in the two target files.
    Verification: Run rg -n -g '*.py' 'httpx2\.((Async)?Client|get|post|put|patch|delete|head|request|stream)\(' src/devops_cli/security/vulnerability_lookup.py src/devops_cli/cloudflare/client.py and confirm it prints nothing.
  • Criterion 2: Each of the four clients is built by new_http_client at EgressLevel.PUBLIC, and ai.allow_private_network does not change that level.
    Verification: Inspect the four call sites in src/devops_cli/security/vulnerability_lookup.py and src/devops_cli/cloudflare/client.py for new_http_client(level=EgressLevel.PUBLIC, ...). Confirm no reference to allow_private_network in those files.
  • Criterion 3: CloudflareRadarClient takes no transport argument.
    Verification: Inspect the CloudflareRadarClient.__init__ signature in src/devops_cli/security/vulnerability_lookup.py and confirm the transport parameter is absent.
  • Criterion 4: test_each_caller_dials_at_its_level has a row for each of the four callers, with and without ai.allow_private_network, resolving the real API host names.
    Verification: Run pytest tests/test_http_egress.py::test_each_caller_dials_at_its_level -v and confirm rows for OSV, Shodan InternetDB, Cloudflare Radar, and Cloudflare API appear for both flag values. Confirm the rows fail on the pre-move code.
  • Criterion 5: All new and existing tests in the affected modules stay offline and each call phase stays under 1 s.
    Verification: Run pytest tests/test_http_egress.py tests/test_http_egress.py -v --timeout=2 and confirm no test exceeds 1 s per call phase and no test opens a real socket.
  • Criterion 6: If the move makes a document wrong, the same pull request fixes it. The general statement that every HTTP client is checked waits for Part 5.
    Verification: Search the repository for statements claiming all HTTP clients are egress-checked and confirm none are added or modified in this pull request beyond the four named clients.
  • Criterion 7: The required CI checks pass.
    Verification: Confirm Static Analysis, Tests & Coverage, and Semantic PR title all report a passing status on the pull request.

Key questions

  • What egress level do the four clients receive?: PUBLIC. The scope table in the issue body assigns each client the public level. [sources: src/devops_cli/security/vulnerability_lookup.py, src/devops_cli/cloudflare/client.py]
  • Does ai.allow_private_network change the level of these four clients?: No. The flag does not widen the level; the clients stay at PUBLIC with or without the flag. [sources: src/devops_cli/http/client.py]
  • What happens to the transport argument of CloudflareRadarClient.init?: It is removed. The factory takes no transport, and no caller in src or tests passes it on d739a47. (proposed) [sources: src/devops_cli/security/vulnerability_lookup.py:466]
  • What timeouts are preserved on the moved clients?: A 1 s connect timeout for OSV, Shodan InternetDB, and Cloudflare Radar. A read timeout of 30.0 s for the Cloudflare API. [sources: src/devops_cli/security/vulnerability_lookup.py:212, src/devops_cli/cloudflare/client.py:366]
  • Does classify_network_target in ShodanInternetDBClient.check_ip stay?: Yes. It decides which addresses the client asks about, not which address the client dials. It is not an egress check. [sources: src/devops_cli/security/vulnerability_lookup.py:374]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/security
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/security. The candidate closes an SSRF gap by routing four clients through the egress-checked factory.
    • Priority: P1-High. A DNS rebinding answer can send the Cloudflare API token to a private address, which is a live security risk.
    • Value: High. It prevents leakage of API tokens to loopback or private addresses via bad DNS answers.
    • Effort: Low. The scope is four named call sites; the change is to replace a raw client build with a factory call and keep timeouts.
    • Related: refactor(cli): Unify HTTP and DNS seams with shared fakes #1314, which asks for a different change. Both work on the HTTP client factory layer; #1314 refactors the factory architecture while this candidate moves four callers to use the existing factory.
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

    Status set to Ready at 19412fa (see proposed design in issue body).

  4. added
    priority/p1-high
    status/ready
    effort/low
    value/high
    on Oct 28, 2026
  5. added a commit that references this issue on Oct 28, 2026
    0379f21
  6. removed
    status/ready
    on Oct 30, 2026
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

    effort/lowpriority/p1-highsource/agenttype/securityvalue/high

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions