Cloudanix VulnDB

CVE-2025-25200

None

Inefficient Regular Expression Complexity in koa

CVSS

—

EPSS

0.8%

Published

Feb 12, 2025

CISA due date

—

Cloudanix analysis

Next patch cycle SSVC: Track

A flaw in some Koa-based web services can let someone slow down or knock the service offline by sending specially crafted web requests.

Exploitation
Remote Unauthenticated
Attacker needs
None
Complexity
Low
Impact
Denial Of Service
Component
Web Framework
Class
Denial of service
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

Koa contains a regular-expression denial-of-service weakness in logic that parses the X-Forwarded-Proto and X-Forwarded-Host HTTP request headers. A remote client can send specially crafted, abnormally long, or adversarially structured forwarded-header values that trigger excessive regular-expression backtracking in the Node.js event loop. Because Node.js applications commonly process requests on a small number of event-loop threads, one or more malicious requests can consume CPU, delay request handling, increase latency, and potentially make the affected Koa application unavailable. The flaw is limited to availability impact; it does not directly provide code execution, authentication bypass, or data disclosure.

Why it matters to the business

Public-facing web applications and APIs built on vulnerable Koa versions may become slow or unavailable when exposed to crafted HTTP requests. Operational consequences can include service outages, elevated error rates, failed transactions, autoscaling cost spikes, incident response effort, and degraded customer experience. The CVE is not currently listed in CISA KEV, is not known to be used in ransomware campaigns, has low EPSS, and has no reported mature public exploit in the provided data, but it has been public for a long time, so remediation should be included in normal dependency maintenance and prioritized higher for internet-facing or high-traffic Koa services.

How an attack unfolds

An attacker identifies a web service implemented with a vulnerable Koa release, typically by fingerprinting application behavior, dependency disclosures, response headers, error pages, package manifests, or by broadly testing Node.js/Koa endpoints. The attacker then sends HTTP requests containing maliciously shaped X-Forwarded-Proto or X-Forwarded-Host header values designed to trigger inefficient regular-expression parsing. When the vulnerable parser evaluates those headers, CPU time is consumed disproportionately compared with the size of the request. Repeating the request, sending it concurrently, or targeting endpoints that pass through Koa proxy-header handling can tie up the Node.js event loop and prevent legitimate requests from being handled promptly. Exploitation requires network access to the application and the ability to supply HTTP headers; it does not require authentication if the vulnerable request path is reachable anonymously.

How to fix it

Upgrade Koa to a version containing the upstream fix. For source-based deployments, ensure the koajs/koa dependency includes commit 93fe903fc966635a991bcf890cfc3427d33a1a08 or a later release that incorporates it. Rebuild and redeploy applications after updating package lockfiles or vendored dependencies so the running artifact actually contains the fixed parser. If immediate upgrade is not possible, mitigate by filtering or normalizing X-Forwarded-Proto and X-Forwarded-Host at a trusted reverse proxy or load balancer, rejecting unusually long forwarded-header values, accepting forwarded headers only from trusted proxy IP ranges, applying request-header size limits, rate-limiting abusive clients, and ensuring application-level timeouts and resource limits are enforced. Do not rely on client-supplied X-Forwarded-* headers unless the application is explicitly behind a trusted proxy chain.

How to confirm the fix worked

Confirm dependency remediation by inspecting package manifests, lockfiles, container images, SBOMs, or vendored source to verify the deployed Koa code is at or after the fixed upstream commit 93fe903fc966635a991bcf890cfc3427d33a1a08 or an equivalent fixed release. Run software composition analysis against production artifacts rather than only source repositories. Validate proxy mitigations by sending benign test requests with oversized X-Forwarded-Proto and X-Forwarded-Host headers and confirming they are rejected, truncated, normalized, or handled without abnormal CPU consumption. Monitor application latency, event-loop delay, CPU usage, and HTTP 4xx/5xx rates during testing to confirm the service remains stable. Verify that only trusted reverse proxies can set forwarded headers and that direct internet clients cannot influence them.

Typical attack path

  1. Discover or select an HTTP service likely to be running a vulnerable Koa application.
  2. Confirm that requests reach Koa header-processing logic, especially code paths that inspect X-Forwarded-Proto or X-Forwarded-Host.
  3. Send crafted HTTP requests with adversarial X-Forwarded-Proto and/or X-Forwarded-Host header values.
  4. Cause excessive regular-expression processing and high CPU usage in the Node.js process.
  5. Repeat or parallelize requests to sustain event-loop blockage, causing latency, timeouts, 5xx responses, or service unavailability.

How to detect it

Review HTTP access logs, reverse-proxy logs, WAF logs, CDN logs, application logs, and Node.js runtime telemetry for periods of high CPU, event-loop lag, request timeouts, or 5xx spikes that correlate with requests containing X-Forwarded-Proto or X-Forwarded-Host headers. Focus on unusually long header values, repeated separators, unexpected schemes or host formats, repeated requests from the same source, and bursts of requests that produce little bandwidth but high server CPU. Check load balancer and reverse-proxy logs for 502, 503, or 504 responses during the same time windows. Application performance monitoring data may show elevated event-loop delay, request queueing, and CPU-bound Node.js processes without corresponding database or downstream-service latency. For forensics, preserve raw request headers where available, correlate source IPs and user agents across affected endpoints, and compare activity before and after deploying the fixed Koa version or header-filtering controls. No named threat actors or ransomware campaigns are indicated in the provided data.

  • X-Forwarded-Proto:
  • X-Forwarded-Host:
  • "X-Forwarded-Proto"
  • "X-Forwarded-Host"
  • x-forwarded-proto
  • x-forwarded-host
  • HTTP 502
  • HTTP 503
  • HTTP 504
  • upstream timed out
  • request timed out
  • event loop lag
  • Event loop delay
  • Node.js CPU
  • node

What your security team should do

  • Inventory internet-facing and internal applications that use koajs/koa, including transitive, vendored, and containerized dependencies.
  • Prioritize upgrade or rebuild of exposed Koa services to include commit 93fe903fc966635a991bcf890cfc3427d33a1a08 or a later fixed release.
  • Enforce reverse-proxy controls that strip untrusted X-Forwarded-Proto and X-Forwarded-Host headers from external clients and re-add trusted values at the edge.
  • Add request-header length limits, rate limits, and anomaly detections for unusually large or malformed X-Forwarded-* headers.
  • Monitor Node.js CPU saturation, event-loop lag, request timeouts, and spikes in 502/503/504 responses for evidence of attempted denial-of-service activity.
  • Include this issue in recurring dependency hygiene despite low current exploitation signals, because the bug is public and easy to reach over HTTP when vulnerable code paths are exposed.

The record

Koa uses an evil regex to parse the `X-Forwarded-Proto` and `X-Forwarded-Host` HTTP headers. This can be exploited to carry out a Denial-of-Service attack.

Affected packages

Ecosystem Package Introduced Fixed
npm koa 0 0.21.2
npm koa 1.0.0 1.7.1
npm koa 2.0.0 2.15.4
npm koa 3.0.0-alpha.0 3.0.0-alpha.3

Related vulnerabilities