Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:0x4m4 Hexstrike ai NVD API Rate Limiting

From Leeroopedia
Knowledge Sources
Domains CVE_Intelligence, Optimization, API_Design
Last Updated 2026-10-10 00:00 GMT

Overview

Rate limiting heuristic enforcing a 6-second delay between NVD API requests for unauthenticated access to avoid HTTP 403 rate-limit rejections.

Description

The NVD API v2.0 limits unauthenticated requests to 5 requests per rolling 30-second window. HexStrike's CVEIntelligenceManager enforces a 6-second time.sleep() between NVD API calls to stay within this limit. When the initial CVE fetch returns no results, the fallback broader search also sleeps for 6 seconds before its request. Failure to respect this limit results in HTTP 403 responses. An optional NVD API key increases the limit to 50 requests per 30 seconds.

Usage

Use this heuristic whenever making sequential NVD API calls. Applied by CVEIntelligenceManager.fetch_latest_cves and CVEIntelligenceManager.analyze_cve_exploitability. Also relevant for any custom code that queries the NVD API.

The Insight (Rule of Thumb)

  • Action: Call time.sleep(6) before each NVD API request when unauthenticated
  • Value: 6 seconds minimum delay between requests
  • Trade-off: Adds latency to CVE fetching (6 seconds per request) but prevents 403 errors and IP throttling
  • With API key: Delay can be reduced to 0.6 seconds (50 requests per 30 seconds)
  • Timeout: Use 30-second request timeout to avoid hanging on slow responses

Reasoning

The NVD API enforces rate limits at the IP level. Unauthenticated requests are capped at 5 per 30 seconds (6 seconds per request average). Exceeding this limit returns HTTP 403, which the code treats as a failure. The 6-second sleep provides a safe margin above the minimum 6-second average. When the initial search finds no CVEs in the specified time window, the code performs a broader 7-day search for critical CVEs—but only after sleeping another 6 seconds to respect the rate limit. This ensures that even rapid sequential calls (initial + fallback) do not trigger throttling.

Code Evidence

Rate limit comment and sleep from `hexstrike_server.py:5984`:

# Add delay to respect NVD rate limits (6 seconds between requests for unauthenticated)
import time

Fallback search with rate limit compliance from `hexstrike_server.py:6097-6098`:

time.sleep(6)  # Rate limit compliance
response = requests.get(nvd_url, params=broader_params, timeout=30)

Request with timeout from `hexstrike_server.py:5988`:

response = requests.get(nvd_url, params=params, timeout=30)

HTTP 403 handling from `hexstrike_server.py:6173-6178`:

if response.status_code != 200:
    logger.warning(f"NVD API returned status {response.status_code} for {cve_id}")
    return {
        "success": False,
        "error": f"Failed to fetch CVE data: HTTP {response.status_code}",
        "cve_id": cve_id
    }

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment