Skip to content

fix(security): a failed shodan internetdb lookup is no ok record - #2647

Merged
dan-petty merged 11 commits into
mainfrom
fix/2504-shodan-failed-lookup-outcome
Oct 29, 2026
Merged

dan-petty merged 11 commits into
mainfrom
fix/2504-shodan-failed-lookup-outcome

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

A failed Shodan InternetDB lookup gave a record with the outcome ok, and the client kept it. A review then showed the address as "Safe / Low Risk". This change makes a lookup that did not succeed read as unchecked in every place that shows it.

  • NetworkReputationRecord.outcome has no default, so a client cannot forget it. A cached record with no outcome is a cache miss.
  • The InternetDB client gives failed for an error and for a status other than 200, 404 and 429. It gives unavailable for 429 and for a domain.
  • The client gives ok only for a 200 or a 404 with the body of InternetDB. Two pydantic models check the bodies, so a proxy that answers 200 with {} no longer shows an address as safe.
  • The client keeps ok records only, so the next call after a failure asks again.
  • The review shows a reference that no lookup answered, as in a dry run, as "Unchecked". The two broad fallbacks of the fetch helpers are deleted, because no public call reaches them.
  • The security_intel_network reply gives the summary only for a failed or unavailable lookup. This holds for Shodan and for Radar.
  • An "Unchecked" reference ranks before every safe one in the report and the table, so a "Safe" row does not hide it. Its color is yellow.

Change: openspec/changes/archive/2026-10-29-2504-shodan-failed-lookup-outcome/

Closes #2504

Plans the change for #2504: a Shodan InternetDB lookup that did not
succeed is no ok record, the record outcome has no default, and the
review and the tool show such a lookup as unchecked.
The InternetDB client gave a failed lookup the model default outcome ok
and kept the record, so a review showed the address as Safe / Low Risk.

- NetworkReputationRecord.outcome has no default and is ok, unavailable
  or failed, so a client cannot forget it.
- The InternetDB client gives failed for an error and for a status other
  than 200, 404 and 429, and unavailable for 429 and for a domain. It
  keeps ok records only, so the next call asks again.
- The review fallbacks name failed or unavailable, and the
  security_intel_network reply names no ports or CVEs for them.
- A cached record with no outcome is a cache miss.

Closes #2504
check_ip and check_domains_batch catch every error of their own, and the
Valkey tier fails soft, so the broad except of the two fetch helpers
ran only under a patch. Delete it. Test the review through
init_per_file_payloads with the shared web fakes, and add no private
import or patch of devops-cli.
…etDB

A reply of 200 or 404 was ok by its status alone. A proxy, a CDN or a
changed route that answers 200 with {} or 404 with an HTML page showed
every public address as safe.

Parse the 200 body as InternetDBHost (ip, ports, vulns) and the 404 body
as InternetDBNoData with pydantic. A body that does not match gives
failed, and the client does not keep it.
…lookup

The reply of security_intel_network for a failed or unavailable Radar
lookup still printed 'Threat Categories: None', which reads as none
found. Print the reputation summary only, as the Shodan reply does.
The rank of Unchecked was 5, below Safe, so deduplication kept a Safe row
over an Unchecked row of one target, and an external Unchecked row was
green. Rank Unchecked after the flagged and medium statuses and before
every safe one, and color it yellow in the report and in the table.
…the rank

Plan the checks of the InternetDB reply bodies, the deleted fallbacks,
the rank and the color of an unchecked reference, and the Radar tool
reply. Record the effect on old findings.json files and name the
follow-up items. Split the long sentences.
@dan-petty dan-petty added scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak labels Oct 29, 2026
@dan-petty

dan-petty commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner Author

Test results for the head of this branch, rebased on origin/main at 9f6ace1.

Targeted tests. uv run devops ci test on the changed sources and test files ran 1248 tests, and all passed. ruff check, ruff format --check, mypy on the changed source modules, devops openspec check and devops docs check also pass. The mypy errors in tests/support/ and in test_read_url_or_authority are older than this branch.

Fail-to-pass. uv run devops ci fail-to-pass --base origin/main replays the tests of this branch on the base tree. 28 tests fail on the base and pass on the head, with 0 errors. Full output: .data/agent/sec/f2p-2504.txt in the author's workspace.

Failing on the base Count
test_shodan_lookup_that_did_not_succeed_is_no_ok_record (12 cases of failed, rate-limited and foreign-body replies) 12
test_cloudflare_radar_error_replies_outcome_and_unverified (no category line) 4
test_reputation_record_needs_a_known_outcome 2
review, tool reply and domain tests of Shodan 4
test_shodan_internetdb_client (outcome of a failed call) 1
test_a_threat_intel_entry_with_no_outcome_is_a_miss 1
rank, merge and color of an unchecked reference 4

Follow-up items filed. Model defaults that read as clean: #2636. A findings.json that does not validate ends a command with a traceback: #2644. The network table colors "Safe / Low Risk" red: #2646.

Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).

@dan-petty
dan-petty marked this pull request as ready for review October 29, 2026 14:33
The change deletes two broad except blocks in pipeline.py, so the ratchet
holds 2 and no longer 4.
The invariant of committed addresses refuses an RFC 1918 address in a
spec. Say a private address, as the scenario means.
@dan-petty
dan-petty merged commit ca9c1ad into main Oct 29, 2026
17 checks passed
@dan-petty
dan-petty deleted the fix/2504-shodan-failed-lookup-outcome branch October 29, 2026 14:45
dan-petty-release Bot added a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.16.3](v0.16.2...v0.16.3)
(2026-10-29)


### Bug Fixes

* **security:** a failed shodan internetdb lookup is no ok record
([#2647](#2647))
([ca9c1ad](ca9c1ad)),
closes [#2504](#2504)

---
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

scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant