CVE-2026-27959: 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.
Security readout for executives and security teams
Plain-English summary
Koa apps that trust ctx.hostname can be tricked into using an attacker-controlled hostname from a malformed Host header. Business risk is highest where that value appears in password reset links, email verification, redirects, tenant routing, or security decisions. The issue is fixed in Koa 3.1.2 and 2.16.4.
Executive priority
Treat as high priority for customer-facing applications using Koa. Prioritize authentication, account recovery, onboarding, and multi-tenant routing services because hostname confusion can undermine trust workflows even without server compromise.
Technical view
Before Koa 3.1.2 and 2.16.4, ctx.hostname naively parsed the Host header by taking text before the first colon and did not validate RFC 3986 hostname syntax. A malformed header containing @ could cause ctx.hostname to return attacker-controlled hostname data. CVSS 3.1 is 8.2, CWE-20.
Likely exposure
Exposure is likely in internet-facing Node.js services using vulnerable Koa versions and referencing ctx.hostname in user-visible links, redirects, routing, or trust decisions. Koa deployments that never use ctx.hostname for those purposes have lower practical risk, but should still upgrade.
Exploitation context
The source bundle does not show CISA KEV listing or confirmed active exploitation. The advisory describes a network-reachable, unauthenticated condition with low attack complexity, but no source here proves exploitation in the wild.
Researcher notes
The issue is input validation failure in hostname parsing, tracked as CWE-20. Analysis should focus on data flow from ctx.hostname into security-sensitive outputs. Evidence in the bundle identifies fixed versions and commits, but does not include exploit proof-of-concept or active exploitation confirmation.
Mitigation direction
Upgrade Koa 3.x to 3.1.2 or later.
Upgrade Koa 2.x to 2.16.4 or later.
Avoid deriving public URLs from request Host headers.
Use a configured canonical base URL for emails and redirects.
Validate allowed hostnames at the edge or application entry point.
Track vendor and Red Hat guidance for downstream package status.
Validation and detection
Inventory Node.js services for Koa dependency versions.
Search application code for ctx.hostname usage.
Review password reset and verification link generation paths.
Confirm generated links use configured trusted hostnames.
Review logs for malformed or unexpected Host header patterns.
Verify Red Hat advisories if using downstream packaged Koa.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cwe · low confidence lookup
CWE-20: Exact CWE lookup
Use the exact CWE identifier as the starting point before reviewing related ATT&CK behavior. Open the exact CWE lookup page first, then review the ATT&CK searches from that MITRE weakness context. This is a Glexia lookup hint, not an official ATT&CK mapping.
The CVE wording references authentication or credential exposure, so valid-account and credential-access review may help. This is a Glexia inferred lookup path, not an official MITRE, ATT&CK, or CVE Program mapping.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.
CWE links open Glexia weakness intelligence pages with official CWE context, developer remediation guidance, and related CVE mappings.
CWE-20 · source CWE mapping
Improper Input Validation
Improper Input Validation represents a recurring weakness pattern that can create exploitable paths when design, validation, or implementation controls are missing.