Skip to content
Heist/ feed
Back to feed
High

Koa has Host Header Injection via `ctx.hostname`

Type: advisorySources: OSV

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.

Products
Not specified
Affected versions
Not specified
Fixed versions
Not specified
CVEs
CVE-2026-27959
Confirmed fixed CVEs
Not specified
Updated in this feed
7 Nov 2026, 01:08 UTC · Revision 1

Source evidence

Koa has Host Header Injection via `ctx.hostname`

core-osv · Original source

Published 26 Feb 2026, 01:45 UTC

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.

osv:CVE-2026-27959
Complete source record
{
  "id": "eb36c75cc30d2fd626d8127c745dbbbcd72c9c421399bac2d5db80733e04f3c7",
  "url": "https://osv.dev/vulnerability/CVE-2026-27959",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "Koa has Host Header Injection via `ctx.hostname`",
    "summary": "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.",
    "evidence": "osv:CVE-2026-27959",
    "products": [],
    "severity": "high",
    "structured": {
      "id": "CVE-2026-27959",
      "aliases": [
        "CVE-2026-27959",
        "GHSA-7gcc-r8m5-44qm"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "repo": "https://github.com/koajs/koa",
              "type": "GIT",
              "events": [
                {
                  "introduced": "0"
                },
                {
                  "fixed": "ca76ea6a4f2f49fb75575730404da146f66cb43c"
                },
                {
                  "introduced": "ead934d8f2e36244336d67ad075c6b2faf4e7267"
                },
                {
                  "fixed": "c5a52e056d61afa012a08d3aa89a59bce5ccbf1b"
                },
                {
                  "fixed": "55ab9bab044ead4e82c70a30a4f9dc0fc9c1b6df"
                },
                {
                  "fixed": "b76ddc01fdb703e51652b0fd131d16394cadcfeb"
                }
              ],
              "database_specific": {
                "extracted_events": [
                  {
                    "cpe": "cpe:2.3:a:koajs:koa:*:*:*:*:*:node.js:*:*",
                    "range": [
                      {
                        "introduced": "0"
                      },
                      {
                        "fixed": "2.16.4"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "cpe": "cpe:2.3:a:koajs:koa:*:*:*:*:*:node.js:*:*",
                    "range": [
                      {
                        "introduced": "3.0.0"
                      },
                      {
                        "fixed": "3.1.2"
                      }
                    ],
                    "source": "CPE_RANGE"
                  },
                  {
                    "range": [
                      {
                        "fixed": "55ab9bab044ead4e82c70a30a4f9dc0fc9c1b6df"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  },
                  {
                    "range": [
                      {
                        "fixed": "b76ddc01fdb703e51652b0fd131d16394cadcfeb"
                      }
                    ],
                    "source": "REFERENCES_COMMIT"
                  }
                ]
              }
            }
          ],
          "versions": [
            "v2.16.3",
            "v3.1.1",
            "v3.1.0",
            "v3.0.3",
            "v2.16.2",
            "v3.0.2",
            "v3.0.1",
            "v2.16.1",
            "v3.0.0",
            "v2.16.0",
            "2.15.4",
            "2.15.3",
            "2.15.2",
            "2.15.1",
            "2.15.0",
            "2.14.2",
            "2.14.1",
            "2.14.0",
            "2.13.4",
            "2.13.3",
            "2.13.2",
            "2.13.1",
            "2.13.0",
            "2.12.1",
            "2.12.0",
            "2.11.0",
            "2.10.0",
            "2.9.0",
            "2.8.2",
            "2.8.1",
            "2.8.0",
            "2.7.0",
            "2.6.2",
            "2.6.1",
            "2.6.0",
            "2.5.3",
            "0.21.0",
            "2.5.2",
            "2.5.1",
            "2.5.0",
            "2.4.1",
            "2.4.0",
            "2.3.0",
            "2.1.0",
            "2.0.1",
            "2.0.0-alpha.8",
            "2.0.0-alpha.7",
            "2.0.0-alpha.6",
            "2.0.0-alpha.5",
            "2.0.0-alpha.4",
            "2.0.0-alpha.3",
            "2.0.0-alpha.2",
            "2.0.0-alpha.1",
            "1.1.0",
            "1.0.0",
            "0.20.0",
            "0.19.1",
            "0.19.0",
            "0.18.1",
            "0.18.0",
            "0.17.0",
            "0.16.0",
            "0.15.0",
            "0.14.0",
            "0.13.0",
            "0.12.2",
            "0.12.1",
            "0.12.0",
            "0.11.0",
            "0.10.0",
            "0.9.0",
            "0.8.2",
            "0.8.1",
            "0.8.0",
            "0.7.0",
            "0.6.3",
            "0.6.2",
            "0.6.1",
            "0.6.0",
            "0.5.5",
            "0.5.4",
            "0.5.3",
            "0.5.2",
            "0.5.1",
            "0.5.0",
            "0.4.0",
            "0.3.0",
            "0.2.1",
            "0.2.0",
            "0.1.2",
            "0.1.1",
            "0.1.0",
            "0.0.2"
          ],
          "database_specific": {
            "source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-27959.json"
          }
        }
      ],
      "modified": "2026-10-28T02:30:48.890865249Z",
      "provider": "osv",
      "references": [
        "https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-27959.json",
        "https://access.redhat.com/errata/RHSA-2026:10184",
        "https://access.redhat.com/errata/RHSA-2026:7249",
        "https://access.redhat.com/security/cve/CVE-2026-27959",
        "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/27xxx/CVE-2026-27959.json",
        "https://github.com/koajs/koa/security/advisories/GHSA-7gcc-r8m5-44qm",
        "https://nvd.nist.gov/vuln/detail/CVE-2026-27959",
        "https://bugzilla.redhat.com/show_bug.cgi?id=2442928",
        "https://github.com/koajs/koa/commit/55ab9bab044ead4e82c70a30a4f9dc0fc9c1b6df",
        "https://github.com/koajs/koa/commit/b76ddc01fdb703e51652b0fd131d16394cadcfeb"
      ],
      "provider_metadata": {
        "cwe_ids": [
          "CWE-20"
        ],
        "cna_assigner": "GitHub_M",
        "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/27xxx/CVE-2026-27959.json"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2026-27959",
        "evidence": "/id"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 516859,
  "published_at": "2026-02-26T01:45:45.668+00:00"
}