Why "0 Matches Found" Is the Most Dangerous Bug in Fraud & Threat-Intel APIs (Fail-Closed DNS, PDF & Registry Design)
In most web APIs, returning an empty list [] is harmless. In a fraud-screening or brand-protection API, returning [] when a check actually failed, timed out, or didn't cover that country is worse than crashing with HTTP
In most web APIs, returning an empty list [] is harmless.
In a fraud-screening or brand-protection API, returning [] when a check actually failed, timed out, or didn't cover that country is worse than crashing with HTTP 500 — because a human buyer reads "0 alerts" as "safe to wire the money".
While hardening Intelliacore in production this week, we caught and fixed three subtle "silent clean" traps across live DNS probing, volatile-RAM PDF inspection, and multi-country registry lookups. Here are the exact failure modes and the fail-closed patterns we replaced them with.
Trap 1: Caching a DNS Outage as "0 Lookalike Domains Found"
Our Brand Watch service generates up to 24 deterministic typosquatting permutations for a brand (lure_combo, homoglyph, transposition, omission, tld_clone), excludes the declared official domain, and resolves them in parallel within a 2.0-second wall budget.
Here is the naive version most developers write first:
# DANGEROUS: confuses NXDOMAIN with DNS timeout / SERVFAIL
def resolve_candidate(domain: str) -> dict | None:
ans = resolve(domain, lifetime=1.4)
if ans.status != DnsStatus.RESOLVES:
return None # <-- timeout looks identical to NXDOMAIN!
return {"domain": domain, "ip": checked_address(ans.addresses)}
Look what happens during a brief upstream DNS hiccup:
- All 24 futures time out or return
SERVFAIL. -
resolvingcomes back as[]. - The API tells the caller: "0 active lookalike permutations out of 24 tested."
-
Worst of all: the 1-hour result cache stores
resolving: [], poisoning every query for that brand for the next 60 minutes!
The Fail-Closed Fix: Explicit Conclusive vs Inconclusive Tracking
We split DNS responses into a strict set of conclusive outcomes vs everything else:
_CONCLUSIVE_DNS_STATUSES = frozenset({
DnsStatus.RESOLVES,
DnsStatus.NO_SUCH_NAME,
DnsStatus.NO_ADDRESS,
})
def _resolve_public_candidate(cand: dict[str, str]) -> tuple[bool, dict[str, Any] | None]:
ans = resolve(cand["domain"], lifetime=1.4)
if ans.status not in _CONCLUSIVE_DNS_STATUSES:
return False, None # inconclusive (timeout, SERVFAIL, network error)
if ans.status != DnsStatus.RESOLVES:
return True, None # conclusively absent
public_ip = checked_address(ans.addresses)
if not public_ip:
return True, None
return True, {"domain": cand["domain"], "technique": cand["technique"], "public_ip": public_ip}
Then we enforce two strict invariants before returning or caching:
inconclusive_count = max(0, len(candidates) - conclusive_count)
out = {
"checked": conclusive_count > 0,
"tested_count": conclusive_count,
"attempted_count": len(candidates),
"inconclusive_count": inconclusive_count,
"resolving": resolving,
}
# Never cache degraded or majority-inconclusive probes!
if use_cache and conclusive_count > 0 and conclusive_count >= inconclusive_count:
probe_cache_set(cache_key, out, ttl_seconds=3600)
And at the verdict layer:
- If DNS is unavailable or majority-inconclusive (with no local threat-list hits), we return
not_checked(risk_score = null) and block blind checkout with HTTP409instead of selling a broken report. - If a fast indexed prefix scan ran instead of a full scan, we never hide that behind
"clean": we return an explicit reduced-scope verdict (partial_scope_no_prefix_matchorpartial_scope_dns_variants_found) spelling out exactly what was and wasn't scanned.
Trap 2: "0 Forgery Signals" on Flat Image-Only or Truncated PDFs
For our zero-storage invoice check (Supplier & Invoice Check), we inspect uploaded PDF bytes strictly in volatile RAM — zero files written to disk — counting incremental binary saves (%%EOF >= 3), extracting IBAN/BIC/SIREN text, and comparing stated banks against embedded IBAN bank codes across 11 European directories.
The trap: what happens if a user uploads a flat scanned image PDF (no selectable text layer, no OCR) or a truncated PDF?
If your pipeline simply runs regex extractors, finds 0 IBANs and < 3 %%EOF markers, and emits risk_score = 10 ("No anomalies found"), you just gave a false green light on a document you couldn't even read!
Our rule:
- If no readable text layer or valid binary trailer can be inspected (and no identifier was pasted alongside), return
verdict_code = "not_checked",risk_score = null, and surface a clear recovery message asking for a text-selectable PDF or pasted IBAN/BIC/company ID — while blocking checkout until at least one real check completes.
Trap 3: Hiding Coverage Gaps Behind Green Checkmarks
Every fraud API has real coverage boundaries:
- Bank-code directories cover specific countries (for us: 11 countries —
FR, MC, MA, DE, NL, BE, CH, ES, IT, LU, GB). - Corporate registries cover specific jurisdictions (
INSEE SIRENE,EU VIES27 states +XI, globalGLEIF LEI). - On-chain public RPC checks cover specific networks (for us:
BTC, ETH, TRX, SOL, TON, whileLTCandXRPvalidate format + OFAC SDN only).
The easiest mistake in UI and JSON schema design is collapsing "not covered" into "no risk found".
Instead, every single check section in our API and printable A4 reports uses a three-state model:
-
verified— check executed conclusively against a live/indexed source. -
alert/warn— concrete discrepancy or list match, always separatingproveninternal evidence fromreportedopen-licensed threat lists (with exact source name and observation date). -
not_checked— outside coverage or upstream unavailable (explicitly labeled"Not checked", never a green pass).
Practical Checklist for Anyone Building Verification APIs
-
Make
not_checkeda first-class status distinct fromclean/0 matchesin your JSON schema, UI, and tests. - Never cache inconclusive upstream errors (DNS timeouts, 5xx registry outages, truncated parses) under the same key as valid negative results.
-
Block paid flows when core probes fail — returning HTTP
409or422beats charging a customer for an empty report. -
Separate
provenvsreportedand attach source + observation date so downstream analysts or AI agents can weigh evidence honestly.
If you want to test these fail-closed states live (we added 1-click real public examples on Brand Watch and Crypto OFAC SDN — including live US Treasury OFAC SDN addresses and real brand lookups — with no signup required), or wire them into Claude/Cursor/n8n:
- Live Brand Watch preview: intelliacore.fr/en/products/brand-phishing-monitoring/
- Live Crypto Wallet & OFAC preview: intelliacore.fr/en/products/crypto-wallet-investigation/
- Open-source MCP server (
npx -y @intelliacore/mcp-afip): GitHub - Open-source n8n community node (
n8n-nodes-intelliacore): GitHub
How do you represent partial coverage and upstream timeouts in your security or compliance APIs without confusing end users?
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.