CVE-2025-25200

7.5 HIGH

📋 TL;DR

Koa middleware for Node.js versions prior to 0.21.2, 1.7.1, 2.15.4, and 3.0.0-alpha.3 contain a regular expression denial-of-service (ReDoS) vulnerability in how they parse X-Forwarded-Proto and X-Forwarded-Host HTTP headers. Attackers can send specially crafted headers to cause excessive CPU consumption and service unavailability. All applications using vulnerable Koa versions are affected.

💻 Affected Systems

Products:
  • Koa
Versions: All versions prior to 0.21.2, 1.7.1, 2.15.4, and 3.0.0-alpha.3
Operating Systems: All platforms running Node.js
Default Config Vulnerable: ⚠️ Yes
Notes: All Koa applications using default configuration are vulnerable if they accept HTTP requests with X-Forwarded headers.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete service outage with high CPU consumption leading to application unavailability for all users.

🟠

Likely Case

Degraded performance and intermittent service disruptions under attack.

🟢

If Mitigated

Minimal impact with proper rate limiting and header validation in place.

🌐 Internet-Facing: HIGH - Attackers can exploit this remotely without authentication via HTTP requests.
🏢 Internal Only: MEDIUM - Internal attackers could still exploit, but attack surface is smaller.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires sending HTTP requests with malicious X-Forwarded headers. No authentication needed.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 0.21.2, 1.7.1, 2.15.4, or 3.0.0-alpha.3

Vendor Advisory: https://github.com/koajs/koa/security/advisories

Restart Required: Yes

Instructions:

1. Check current Koa version with 'npm list koa'. 2. Update to patched version: 'npm update koa@latest' or specify exact version. 3. Restart Node.js application. 4. Verify fix with version check.

🔧 Temporary Workarounds

Header Validation Middleware

all

Add custom middleware to validate or strip X-Forwarded headers before Koa processes them.

// Add this middleware before other Koa middleware
app.use(async (ctx, next) => {
  // Remove or validate X-Forwarded headers
  delete ctx.headers['x-forwarded-proto'];
  delete ctx.headers['x-forwarded-host'];
  await next();
});

Rate Limiting

all

Implement rate limiting to prevent excessive header attacks.

npm install koa-ratelimit
// Configure rate limiting middleware

🧯 If You Can't Patch

  • Implement reverse proxy or WAF to filter malicious X-Forwarded headers before they reach Koa.
  • Deploy application-level rate limiting to restrict request frequency from single sources.

🔍 How to Verify

Check if Vulnerable:

Check package.json or run 'npm list koa' to see installed version. Compare against vulnerable versions.

Check Version:

npm list koa | grep koa

Verify Fix Applied:

After update, run 'npm list koa' to confirm version is 0.21.2, 1.7.1, 2.15.4, or 3.0.0-alpha.3 or higher.

📡 Detection & Monitoring

Log Indicators:

  • High CPU usage spikes
  • Increased request processing time
  • Multiple requests with X-Forwarded headers from same source

Network Indicators:

  • HTTP requests containing X-Forwarded-Proto or X-Forwarded-Host headers with unusual patterns

SIEM Query:

source="web_logs" AND (header="X-Forwarded-Proto" OR header="X-Forwarded-Host") AND request_time > 5s

🔗 References

📤 Share & Export