Koa
Koa has Host Header Injection via `ctx.hostname`
Koa is middleware for Node.js using ES2017 async functions. Prior to versions 3.1.2 and 2.16.4, Koa's `ctx.hostname` API performs naive parsing of the HTTP Host header, extracting everything before the first colon without validating the input conforms to RFC 3986 hostname syntax. When a malformed Host header containing a `@` symbol is received, `ctx.hostname` returns `evil[.]com` - an attacker-controlled value. Applications using `ctx.hostname` for URL generation, password reset links, email verification URLs, or routing decisions are vulnerable to Host header injection attacks. Versions 3.1.2 and 2.16.4 fix the issue.
Affected versions and mitigation
From the CVE record and the vendor's references.Affected
- >= 3.0.0, < 3.1.2
- < 2.16.4
Fixed in 3.1.2, 2.16.4
Mitigation
Upgrade koa to 3.1.2 or 2.16.4 or later.
References
Timeline
Days relative to CVE publicationFirst public PoC 12 days after publication; not in CISA KEV. First PoC: mlouazir/CVE-2026-27959-mini-lab (created 9 Mar 2026, found by us: backfilled).
PoC repositories
Found on GitHub.1 PoCs
PoCs 1
| Repository | Created | Stars | Assessment |
|---|---|---|---|
| mlouazir/CVE-2026-27959-mini-lab | 9 Mar 2026 +12 d | 0 | PoC
Flags · score 15
Below the suspicion threshold (50); does not change the assessment. |
Only PoCs count toward the first-PoC date and the characteristics below. Do not run PoC code from unknown sources.
PoC characteristics
What to hunt for in your logs · from 1 PoC repoGET /
- Key headers
Host: localhost@evil.com- Ports
- 3000
- Seen in
- 1 repo: mlouazir/CVE-2026-27959-mini-lab
- Evidence
- mlouazir/CVE-2026-27959-mini-lab/app.js:6
Regex
Generated from PoC characteristics; not yet reviewed. Matches the request path and query.
(?i)^/(?:[?#].*)?$
Suricata
Template generated from PoC characteristics. Review before deploying.
alert http any any -> $HOME_NET [3000] (msg:"GG PoC-Monitor CVE-2026-27959 koajs koa exploit attempt"; flow:established,to_server; http.method; content:"GET"; http.header; content:"Host: localhost@evil.com"; nocase; reference:url,poc.griffinguard.io/cve/CVE-2026-27959; classtype:web-application-attack; sid:9859032; rev:1;)
Sigma
Template generated from PoC characteristics. Review before deploying.
title: koajs koa exploit attempt (CVE-2026-27959)
id: gg-pocmon-cve-2026-27959-9859032
status: experimental
description: Request pattern taken from public PoCs for CVE-2026-27959. Generated, not reviewed.
references:
- https://poc.griffinguard.io/cve/CVE-2026-27959
logsource:
category: webserver
detection:
selection:
cs-method: GET
condition: selection
falsepositives:
- Authorized vulnerability scanning
level: high
tags:
- attack.initial_access
- attack.t1190
- cve.2026.27959