Dev.to Security 🔐 Cybersecurity 👁 2 📖 4 min read

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:

  1. All 24 futures time out or return SERVFAIL.
  2. resolving comes back as [].
  3. The API tells the caller: "0 active lookalike permutations out of 24 tested."
  4. 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 HTTP 409 instead 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_match or partial_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 VIES 27 states + XI, global GLEIF LEI).
  • On-chain public RPC checks cover specific networks (for us: BTC, ETH, TRX, SOL, TON, while LTC and XRP validate 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:

  1. verified — check executed conclusively against a live/indexed source.
  2. alert / warn — concrete discrepancy or list match, always separating proven internal evidence from reported open-licensed threat lists (with exact source name and observation date).
  3. not_checked — outside coverage or upstream unavailable (explicitly labeled "Not checked", never a green pass).

Practical Checklist for Anyone Building Verification APIs

  1. Make not_checked a first-class status distinct from clean / 0 matches in your JSON schema, UI, and tests.
  2. Never cache inconclusive upstream errors (DNS timeouts, 5xx registry outages, truncated parses) under the same key as valid negative results.
  3. Block paid flows when core probes fail — returning HTTP 409 or 422 beats charging a customer for an empty report.
  4. Separate proven vs reported and 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:

How do you represent partial coverage and upstream timeouts in your security or compliance APIs without confusing end users?

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.