CVE-2026-27959

7.5 HIGH

📋 TL;DR

This vulnerability in Koa.js allows attackers to inject malicious hostnames via specially crafted HTTP Host headers containing '@' symbols. Applications using ctx.hostname for security-sensitive operations like URL generation, password reset links, or routing decisions are vulnerable to host header injection attacks. All Koa.js applications using affected versions are at risk.

💻 Affected Systems

Products:
  • Koa.js
Versions: All versions before 2.16.4 and 3.1.2
Operating Systems: All operating systems running Node.js
Default Config Vulnerable: ⚠️ Yes
Notes: Only applications using ctx.hostname API are vulnerable. Applications not using this API are not affected.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers could redirect password reset or email verification links to malicious domains, leading to account takeover, phishing attacks, or session hijacking.

🟠

Likely Case

Attackers could manipulate generated URLs to redirect users to malicious sites or bypass security controls that rely on hostname validation.

🟢

If Mitigated

With proper input validation and security controls, the impact is limited to potential logging anomalies or minor functionality issues.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires sending a malformed Host header with '@' symbol. Public proof-of-concept exists in the advisory.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2.16.4 or 3.1.2

Vendor Advisory: https://github.com/koajs/koa/security/advisories/GHSA-7gcc-r8m5-44qm

Restart Required: Yes

Instructions:

1. Update Koa.js package using npm: 'npm update koa' 2. Verify version is 2.16.4+ or 3.1.2+ 3. Restart Node.js application

🔧 Temporary Workarounds

Input Validation Middleware

all

Add middleware to validate Host header before Koa processes it

app.use(async (ctx, next) => { if (ctx.request.host.includes('@')) { ctx.throw(400, 'Invalid Host header'); } await next(); })

🧯 If You Can't Patch

  • Implement reverse proxy with strict Host header validation
  • Add application-level validation for all ctx.hostname usage

🔍 How to Verify

Check if Vulnerable:

Check if application uses ctx.hostname and test with Host header containing '@' symbol

Check Version:

npm list koa

Verify Fix Applied:

Test with malformed Host header containing '@' - should return proper error or sanitized value

📡 Detection & Monitoring

Log Indicators:

  • HTTP requests with Host headers containing '@' symbols
  • Unexpected hostname values in application logs

Network Indicators:

  • HTTP requests with malformed Host headers
  • Unusual redirect patterns

SIEM Query:

http.request.headers.host CONTAINS '@'

🔗 References

📤 Share & Export