Skip to content

fix(security): a failed shodan internetdb lookup has outcome failed, so a review never shows its address as safe #2504

Description

@dan-petty

Problem Description

When a Shodan InternetDB lookup fails, ShodanInternetDBClient.check_ip (src/devops_cli/security/vulnerability_lookup.py) gives a record with outcome="ok". The except branch sets only the summary "Unchecked / Lookup timeout". It does not set outcome, so the record keeps the model default "ok" (NetworkReputationRecord.outcome in src/devops_cli/models/vulnerability.py). The client also keeps the failed record in self._cache for the life of the client, so the address is not asked about again.

The review pipeline shows a network reference as "Unchecked" only when outcome is unavailable or failed (_determine_network_security_status in src/devops_cli/ai/review/pipeline.py). Thus a failed lookup of a public address shows as "✓ Safe / Low Risk". This is the same defect that #1429 fixed for Cloudflare Radar: a failed lookup must be reported as unavailable or failed, never as verified.

A lookup fails at a timeout, at a failed connect, and, after #2430, when the egress-checked factory refuses a non-public DNS answer for internetdb.shodan.io.

Reproduction Steps

  1. Stub socket.getaddrinfo to answer 10.0.0.1 for internetdb.shodan.io, and make socket.socket.connect raise OSError.
  2. Run ShodanInternetDBClient().check_ip("93.184.215.14").
  3. Read outcome and reputation_summary of the record, and see if the client cached the record.

The same result comes from any failed connect or timeout before #2430.

Expected vs Actual Behavior

Expected: a failed lookup gives outcome="failed", as CloudflareRadarClient and OSVClient do. The review shows the reference as "Unchecked". A decision on the cache of a failed record is recorded (Radar keeps a failed record in its in-memory cache and not in Valkey; OSV caches no failed lookup).

Actual: outcome="ok", summary "Unchecked / Lookup timeout", and the record is cached. The review shows the reference as "✓ Safe / Low Risk".

Environment Diagnostics

devops-cli 0.10.0, from the source tree of the topic branch of #2430. Linux, Python 3.14. The probe made no network request.

Logs, Traces, or Terminal Output

outcome: ok | summary: Unchecked / Lookup timeout
cached: True

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: #2430

Proposed design

Problem statement

A failed Shodan InternetDB lookup keeps the model default outcome "ok" because the except branch does not set it. The review pipeline reads outcome and shows the address as "Safe / Low Risk" instead of "Unchecked". The failed record is also cached, so the address is never re-checked for the life of the client.

Acceptance criteria

  • Criterion 1: A failed Shodan InternetDB lookup returns a record with outcome set to "failed".
    Verification: Stub socket.getaddrinfo to answer a private address and make socket.socket.connect raise OSError. Call ShodanInternetDBClient().check_ip("93.184.215.14"). Assert record.outcome equals "failed".
  • Criterion 2: The review pipeline shows a failed Shodan lookup as "Unchecked".
    Verification: Call _determine_network_security_status with a NetworkReputationRecord whose outcome is "failed". Assert the return value is "Unchecked".
  • Criterion 3: A failed Shodan InternetDB record is not stored in the client in-memory cache.
    Verification: After a failed check_ip call, assert the ip key is not in client._cache.
  • Criterion 4: A successful Shodan InternetDB lookup (200 or 404) is still cached.
    Verification: Stub the HTTP client to return 200 or 404. Call check_ip. Assert the ip key is in client._cache and outcome is "ok".

Key questions

  • What outcome value should a failed Shodan InternetDB lookup record carry?: "failed". This matches CloudflareRadarClient, which sets record.outcome = "failed" in its except block, and OSVClient, which returns a result with status "failed". The value "unavailable" is reserved for rate-limiting (HTTP 429) in Radar. (best practice) [sources: src/devops_cli/security/vulnerability_lookup.py, src/devops_cli/models/vulnerability.py]
    • Chosen: failed. Matches CloudflareRadarClient and OSVClient. The pipeline already maps "failed" to "Unchecked".
    • Rejected: unavailable. Radar uses this only for HTTP 429 rate limiting. A connect failure or timeout is a failure, not an availability signal.
    • Rejected: ok (current default). This is the defect. It causes the pipeline to show the address as Safe.
  • Should a failed Shodan InternetDB record be cached in the client in-memory cache?: No. A failed record is not cached. This matches OSVClient, which writes to its cache only in the try block and returns a failed result without caching on exception. Not caching allows the next call to retry the lookup after a transient failure. (best practice) [sources: src/devops_cli/security/vulnerability_lookup.py]
    • Chosen: Do not cache failed records. Matches OSVClient. A transient network failure does not permanently block re-checking. Simpler logic: the cache write stays in the try block.
    • Rejected: Cache failed records in L1 only. Matches CloudflareRadarClient L1 behavior. But Shodan has no L2 tier, and a single transient failure would block re-checking for the life of the client. The body lists this as part of the defect.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/security
    status/new
    value/high
    effort/low
    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.

    • Type: type/security. A failed security lookup is reported as safe, which is a false negative in security tooling.
    • Priority: P1-High. A security tool showing an unchecked address as Safe misleads users into a false sense of protection.
    • Value: High. Users rely on the review to flag unverified addresses; a false Safe result undermines trust in the entire security pipeline.
    • Effort: Low. The fix sets outcome to failed in one except branch and adjusts one cache decision, as done for Cloudflare Radar in #1429.
    • Related: feat(cli): scanner outcome status unavailable, failed or unqueried is not clean #708, which asks for a different change. Both address failed security lookups shown as safe, but #708 fixes the scanner report pipeline while this fixes the Shodan client outcome field and cache.
  3. added
    priority/p1-high
    on Oct 28, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 29, 2026
  5. devops-cli-service commented on Oct 29, 2026

    @devops-cli-service
    Contributor

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

  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

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions