CVE-2026-27959 Koa has Host Header Injection via `ctx.hostname`

High 7.5 Published Updated

Koa's hostname parsing flaw allows Host header injection, enabling attackers to manipulate generated URLs for password resets or routing.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2026-27959?

CVE-2026-27959 is a high-severity vulnerability in koajs koa, published on 26 Feb 2026. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

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.

Weakness: CWE-20

Which versions are affected by CVE-2026-27959?

4 open source packages ship an affected version, including koa. It affects 1 product.

PackageAffectedFixed in
koa npmAll versions2.16.4
koa npmAll versions2.16.4
koa npmFrom 3.0.03.1.2
koa npmFrom 3.0.03.1.2

Products include Koajs Koa.

How do I fix CVE-2026-27959?

Upgrade koa to a fixed version for your release line: 2.16.4 or 3.1.2.

Is CVE-2026-27959 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-27959 exists.

Public exploit code: 1 proofs of concept on GitHub.

Sources

Also known as CLSA-2026-1788264598, GHSA-7gcc-r8m5-44qm, ROOT-APP-NPM-CVE-2026-27959.

Is CVE-2026-27959 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free