CVE-2025-62595: Koa Koa Vulnerable To Open Redirect Vulnerability
MODERATECVE-2025-62595 is a MODERATE (CVSS 4.7) koa vulnerable to open redirect vulnerability (CWE-601: URL Redirection to Untrusted Site ('Open Redirect')) affecting Koa libraries in the npm ecosystem. The issue involves koa vulnerable to open redirect via trailing double-slash (//) in back redirect logic. Remediation is available by upgrading affected packages to version 3.0.3, 2.16.3.
CVE-2025-62595 at a Glance
Security Impact
CVSS: 4.7
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:L/A:N).
How to Fix CVE-2025-62595
To remediate this vulnerability, upgrade all affected Koa dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install koa@3.0.3
npm install koa@2.16.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls koa
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2025-62595, inspect your project dependencies using npm:
npm ls koa
Analyze the terminal output to locate any version of Koa in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.3), your application is affected.
Note: The npm ls koa command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect'), where the web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. In Koa, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-62595 Affected Koa Versions
2 component(s)References
Frequently Asked Questions
What is CVE-2025-62595?
Which Koa versions are affected?
What version fixes CVE-2025-62595?
Is koa affected?
What is the CVSS score of CVE-2025-62595?
What CWE is associated with CVE-2025-62595?
How can I check npm dependencies for CVE-2025-62595?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-g8mr-fgfg-5qpc",
"modified" : "2026-01-21T16:15:45Z",
"published" : "2025-10-21T15:09:06Z",
"aliases" : [ "CVE-2025-62595" ],
"summary" : "Koa Vulnerable to Open Redirect via Trailing Double-Slash (//) in back Redirect Logic",
"details" : "### Summary:\n\nA bypass was discovered in the `Koa.js` framework affecting its back redirect functionality. In certain circumstances, an attacker can manipulate the Referer header to force a user’s browser to navigate to an external, potentially malicious website. This occurs because the implementation incorrectly treats some specially crafted URLs as safe relative paths. Exploiting this vulnerability could allow attackers to perform phishing, social engineering, or other redirect-based attacks on users of affected applications.\n\nThis vulnerability affects the code referenced in GitHub Advisory GHSA-jgmv-j7ww-jx2x (which is tracked as CVE‑2025‑54420). \n\n### Details:\nThe patched code attempts to treat values that `startWith('/')` as safe relative paths and only perform origin checks for absolute URLs. However, protocol‑relative URLs (those beginning with //host) also start with '/' and therefore match the startsWith('/') branch. A protocol‑relative referrer such as `//evil.com` with trailing double-slash is treated by the implementation as a safe relative path, but browsers interpret Location: //evil.com as a redirect to https://evil.com (or http:// based on context).\nThis discrepancy allows an attacker to supply Referer: //evil.com and trigger an external redirect - bypassing the intended same‑origin protection.\n\n### Proof of concept (PoC):\nAffected line of code: https://github.com/koajs/koa/blob/master/lib/response.js#L326\nThe problematic logic looks like:\n\n<img width=\"567\" height=\"509\" alt=\"3\" src=\"https://github.com/user-attachments/assets/33de440a-8945-4e5f-9e0a-2011a3999458\" />\n\nRequest with a protocol‑relative Referer:\ncurl -i -H \"Referer: //haymiz.dev\" http://127.0.0.1:3000/test\n\n<img width=\"2072\" height=\"1005\" alt=\"1\" src=\"https://github.com/user-attachments/assets/55c48c79-559d-46aa-8b76-c1d2d3536c8b\" />\n\nVulnerable response will contain:\nHTTP/1.1 302 Found\nLocation: //haymiz.dev\n\nA browser receiving that Location header navigates to https://haymiz.dev (or http:// depending on context), resulting in an open redirect to an attacker‑controlled host:\n\n<img width=\"454\" height=\"239\" alt=\"2\" src=\"https://github.com/user-attachments/assets/852ae81a-9f63-49c1-9ce5-72cd96bcea68\" />\n\n### Recommendation / Patch:\n* Do not treat //host as a safe relative path. Explicitly exclude protocol‑relative values from any relative‑path branch.\n* Normalize the Referer by resolving it with a base (e.g., new URL(rawRef, ctx.href)), then compare resolved.origin (scheme+host+port) to ctx.origin (or ctx.host plus scheme/port) before allowing the redirect.\n\n### Impact:\nAn attacker who can cause a victim to visit a specially crafted link (or inject a request with a controlled Referer) can cause the victim to be redirected to an attacker‑controlled domain. This can be used for phishing, social engineering, or to bypass some protection rules that rely on same‑origin navigation.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "koa"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "3.0.1"
}, {
"fixed" : "3.0.3"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "koa"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.16.2"
}, {
"fixed" : "2.16.3"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/koajs/koa/security/advisories/GHSA-g8mr-fgfg-5qpc"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-62595"
}, {
"type" : "WEB",
"url" : "https://github.com/koajs/koa/commit/769fd75cc6b30d72493b370b5a3ae2332ca03c5b"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/koajs/koa"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-601" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-10-21T15:09:06Z",
"nvd_published_at" : "2025-10-21T17:15:40Z"
}
}