CVE-2026-23996
Python vulnerability analysis and mitigation

Overview

CVE-2026-23996 is a timing side-channel vulnerability in the fastapi-api-key Python library (also known as keyshield) that allows unauthenticated remote attackers to statistically distinguish valid from invalid API keys by measuring response latencies. The flaw exists in the verify_key() method, which applied a random delay only on verification failures — not on successes — creating an observable timing discrepancy. All versions of fastapi-api-key prior to 1.1.0 are affected. The vulnerability was published on January 21, 2026, with a patch released the same day. It carries a CVSS v3.1 base score of 3.7 (Low) (GitHub Advisory).

Technical details

The root cause is classified as CWE-208 (Observable Timing Discrepancy). In the vulnerable implementation, verify_key() wrapped only the exception path with a randomized sleep (uniform(rrd, rrd * 2)), meaning successful authentications returned faster than failures. An attacker with network access could send repeated requests with candidate key_id values and use statistical analysis of response times to infer whether a given key identifier is valid, effectively enabling key enumeration without triggering a full brute-force of the secret portion. The fix (commit 310b2c5) introduces a _apply_delay() helper that calls asyncio.sleep(uniform(min_delay, max_delay)) unconditionally on both success and failure paths, and deprecates the old rrd parameter in favor of explicit min_delay/max_delay arguments (GitHub Advisory, Patch Commit).

Impact

Successful exploitation leaks low-confidence confidentiality information: an attacker can determine whether a given key_id corresponds to a registered API key, narrowing the search space for brute-force or enumeration attacks against the authentication system. There is no direct integrity or availability impact. The practical risk is that an adversary could accelerate credential-guessing campaigns against APIs protected by this library, potentially leading to unauthorized access if combined with further attacks (GitHub Advisory).

Exploitability

No public exploit code or in-the-wild exploitation has been reported for this vulnerability. The EPSS score is approximately 0.038% (0.000380), placing it in the 20th percentile for exploitation likelihood within 30 days. The attack complexity is rated High, as statistical timing attacks require a large number of repeated requests and controlled network conditions to yield reliable results. The vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog (GitHub Advisory).

Exploitation steps

  1. Reconnaissance: Identify FastAPI applications using the fastapi-api-key library (versions < 1.1.0) by inspecting API responses, error messages, or dependency manifests (e.g., requirements.txt, PyPI metadata).
  2. Enumerate key_id candidates: Craft API requests using candidate key_id values (the public identifier portion of an API key) against the authentication endpoint protected by verify_key().
  3. Measure response latencies: Send a large number of requests (hundreds to thousands) for each candidate key_id, recording precise response times using a high-resolution timer. Requests with valid key_id values will consistently return faster (no injected delay), while invalid ones will include the random delay.
  4. Statistical analysis: Apply statistical methods (e.g., mean comparison, t-test) to the collected latency samples to distinguish valid key_id values from invalid ones based on the timing distribution.
  5. Accelerate brute-force: Use confirmed valid key_id values to focus brute-force or guessing efforts on the secret portion of the API key, reducing the overall search space (GitHub Advisory).

Indicators of compromise

  • Network: High volume of repeated authentication requests to API endpoints from a single IP or small IP range, particularly with varying key_id values but consistent request structure.
  • Logs: Authentication failure logs showing a large number of KeyNotFound or InvalidKey errors in rapid succession from the same source, potentially interleaved with occasional successes; unusual patterns of requests cycling through many different key identifiers.
  • Application Metrics: Anomalous spike in authentication endpoint request rate without a corresponding increase in successful authentications; statistical clustering of response times that may indicate timing measurement activity.

Mitigation and workarounds

Users should upgrade fastapi-api-key to version 1.1.0, which applies a uniform random delay (min_delay to max_delay, defaulting to 0.1–0.3 seconds) to all verify_key() responses regardless of outcome, eliminating the timing correlation. For those unable to upgrade immediately, two workarounds are available: (1) add an application-level fixed delay or random jitter to all authentication responses (both success and failure) before the library's response is returned; and (2) implement rate limiting on authentication endpoints to reduce the feasibility of statistical timing attacks. The rrd parameter is deprecated in v1.1.0 and replaced by the explicit min_delay/max_delay parameters (GitHub Advisory, Release 1.1.0).

Additional resources


SourceThis report was generated using AI

Related Python vulnerabilities:

CVE ID

Severity

Score

Technologies

Component name

CISA KEV exploit

Has fix

Published date

CVE-2026-50027CRITICAL9.8
  • Python logoPython
  • mcp-memory-service
NoYesAug 14, 2026
CVE-2026-49986HIGH7.1
  • Python logoPython
  • neuro-cortex-memory
NoYesAug 14, 2026
CVE-2026-53708MEDIUM6.6
  • Python logoPython
  • mcp-contextforge-gateway
NoYesAug 14, 2026
CVE-2026-47192LOW2.1
  • Python logoPython
  • kas
NoYesAug 14, 2026
CVE-2026-47191LOW2.1
  • Python logoPython
  • kas
NoYesAug 14, 2026

Free Vulnerability Assessment

Benchmark your Cloud Security Posture

Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.

Request assessment

Get a personalized demo

Ready to see Wiz in action?

"Best User Experience I have ever seen, provides full visibility to cloud workloads."
David EstlickCISO
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
Adam FletcherChief Security Officer
"We know that if Wiz identifies something as critical, it actually is."
Greg PoniatowskiHead of Threat and Vulnerability Management