CVE-2021-21321

10.0 CRITICAL

📋 TL;DR

CVE-2021-21321 is a path traversal vulnerability in fastify-reply-from npm package that allows attackers to bypass URL prefix restrictions when proxying requests. By crafting specific URLs, attackers can access backend services outside the intended proxied prefix. This affects all applications using vulnerable versions of fastify-reply-from for request forwarding.

💻 Affected Systems

Products:
  • fastify-reply-from
Versions: All versions before 4.0.2
Operating Systems: All
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using fastify-reply-from for request proxying with prefix configurations.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers could access unauthorized backend endpoints, potentially exposing sensitive internal services, confidential data, or administrative interfaces that should be protected behind the proxy.

🟠

Likely Case

Unauthorized access to backend services that should be restricted, potentially leading to information disclosure or privilege escalation depending on what services are exposed.

🟢

If Mitigated

With proper network segmentation and authentication layers, impact is limited to the specific proxied service rather than full backend compromise.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires crafting URLs with specific patterns to bypass prefix checks. Public advisory includes technical details.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 4.0.2

Vendor Advisory: https://github.com/fastify/fastify-reply-from/security/advisories/GHSA-qmw8-3v4g-gwj4

Restart Required: Yes

Instructions:

1. Update package.json to specify 'fastify-reply-from': '^4.0.2' 2. Run 'npm update fastify-reply-from' 3. Restart your application 4. Verify the update with 'npm list fastify-reply-from'

🔧 Temporary Workarounds

Input validation middleware

all

Add custom middleware to validate and sanitize URLs before they reach fastify-reply-from

Reverse proxy restrictions

all

Configure upstream reverse proxies (nginx, Apache) to enforce URL path restrictions

🧯 If You Can't Patch

  • Implement strict URL validation and sanitization in application code
  • Deploy WAF rules to block path traversal patterns in URLs

🔍 How to Verify

Check if Vulnerable:

Check package.json or run 'npm list fastify-reply-from' to see if version is below 4.0.2

Check Version:

npm list fastify-reply-from | grep fastify-reply-from

Verify Fix Applied:

After update, confirm version is 4.0.2 or higher with 'npm list fastify-reply-from'

📡 Detection & Monitoring

Log Indicators:

  • Unusual URL patterns with encoded characters, requests to unexpected backend paths, 404 errors from backend services for paths that should be blocked

Network Indicators:

  • HTTP requests with crafted URLs containing path traversal sequences, requests bypassing expected URL prefixes

SIEM Query:

http.url:*%2F..%2F* OR http.url:*%2F.%2F* OR http.url:*//* targeting applications using fastify-reply-from

🔗 References

📤 Share & Export