CVE-2025-62595: Koa Vulnerable to Open Redirect via Trailing Double-Slash (//) in back Redirect Logic
4.7
Basic Information
Technical Details
| Package Name | Ecosystem | Vulnerable Versions | First Patched Version |
|---|---|---|---|
| koa | npm | >= 3.0.1, < 3.0.3 | 3.0.3 |
| koa | npm | >= 2.16.2, < 2.16.3 | 2.16.3 |
Vulnerability Intelligence
Miggo AI
Root Cause Analysis
The vulnerability analysis began by examining the provided commit 769fd75cc6b30d72493b370b5a3ae2332ca03c5b, which was identified as the patch for the open redirect issue in Koa. The commit modified lib/response.js. The key change was the removal of a code block within the back function. This removed block checked if the Referrer header started with / and, if so, performed a redirect, assuming it was a safe relative path. The vulnerability description and the test case added in __tests__/response/back.test.js confirm that this logic was flawed because protocol-relative URLs (e.g., //evil.com) also start with / but are interpreted by browsers as external URLs. By removing this check, the patch ensures that all referrer URLs are properly parsed and their origin is validated against the application's host, thus closing the open redirect vulnerability. The vulnerable function is therefore back in lib/response.js, as it contained the logic that processed the malicious Referrer header and triggered the unsafe redirect.
Vulnerable functions
backlib/response.js