CVE-2026-27959: Koa Host Header Injection Vulnerability

koa Updated 27 Feb 2026

Summary

26/02/2026
Yes i
High
7.5

CVE-2026-27959: Koa has Host Header Injection via ctx.hostname. Affects koa across 2 version ranges.

< 2.16.4 >= 3.0.0, < 3.1.2

Fixed in 2.16.4 or 3.1.2, depending on the release line you run. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Koa is a popular Node.js web framework designed for building web applications and APIs. It provides a robust set of features for web and mobile applications, including middleware support, routing, and a simplified API. However, Koa's handling of the HTTP Host header has a vulnerability that can lead to serious security issues, particularly in applications that rely on the ctx.hostname API for generating URLs and routing decisions.

Vulnerability Detail

The vulnerability arises from Koa's naive parsing of the HTTP Host header in its ctx.hostname API. When a malformed Host header is received, such as one containing an '@' symbol, Koa incorrectly extracts the hostname, allowing an attacker to control the value returned by ctx.hostname. This can lead to various attacks, including password reset poisoning, email verification bypass, and OAuth callback manipulation, all of which can compromise user accounts and sensitive data.

How To Fix

Latest published version: 3.2.1 as of 22 Oct 2026

npm install koa@3.2.1

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 2.16.4 2.16.4
    npm install koa@2.16.4
  • >= 3.0.0, < 3.1.2 3.1.2
    npm install koa@3.1.2

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

As a temporary workaround, you can implement additional validation for the Host header in your application. For example, you can manually check the value of ctx.get('Host') and ensure it conforms to valid hostname formats before using it in your application logic. Here’s a simple example:

const validHost = (host) => /^[a-zA-Z0-9.-]+$/.test(host);

app.use(async ctx => {
  const host = ctx.get('Host');
  if (!validHost(host)) {
    ctx.throw(400, 'Invalid Host header');
  }
  // Proceed with your application logic
});

Conclusion

The Koa Host Header Injection vulnerability (CVE-2026-27959) poses significant risks to applications that utilize the ctx.hostname API without proper validation. It is crucial for developers to update to the latest patched versions of Koa and implement additional validation measures to safeguard their applications against potential attacks.

See every vulnerability recorded for koa →

Share this vulnerability

FAQ

The vulnerability allows attackers to inject malicious Host headers, leading to potential account takeover and other security issues.

If your application uses Koa and relies on ctx.hostname for URL generation or routing, it may be vulnerable. You can check your application using Vulert's playground at Vulert Scanner.

Consequences include password reset poisoning, email verification bypass, and OAuth callback manipulation, which can lead to unauthorized access to user accounts.

Yes, you can implement custom validation for the Host header as a temporary workaround until you can update to a patched version.

The CVSS score for this vulnerability is 7.5, indicating a high severity level.

Related vulnerabilities

Recent vulnerabilities recorded for koa.

How To Fix

Latest published version: 3.2.1 as of 22 Oct 2026

npm install koa@3.2.1

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 2.16.4 2.16.4
    npm install koa@2.16.4
  • >= 3.0.0, < 3.1.2 3.1.2
    npm install koa@3.1.2

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback