CVE-2025-8129: Koa Koa Open Redirect Vulnerability

LOW
Advisory Identifier: GHSA-jgmv-j7ww-jx2x
CVSS 3.5
CWE-601
Published
Advisory Summary

CVE-2025-8129 is a LOW (CVSS 3.5) koa open redirect vulnerability (CWE-601: URL Redirection to Untrusted Site ('Open Redirect')) affecting Koa libraries in the npm ecosystem. The issue involves koa open redirect via referrer header (user-controlled). Remediation is available by upgrading affected packages to version 2.16.2, 3.0.1.

CVE-2025-8129 at a Glance

CVE Identifier CVE-2025-8129
GHSA Identifier GHSA-jgmv-j7ww-jx2x
Severity LOW
CVSS v3.1 Base Score 3.5
CWE Classification CWE-601: URL Redirection to Untrusted Site ('Open Redirect')
Affected Product Koa
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 3.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2025-8129

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.

koa fixed: 2.16.2
npm install koa@2.16.2
koa fixed: 3.0.1
npm install koa@3.0.1
Verify Direct and Transitive Dependencies

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-8129, 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 2.16.2), 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

## Summary In the latest version of Koa, the back method used for redirect operations adopts an insecure implementation, which uses the user-controllable referrer header as the redirect target. ## Details on the API document https://www.koajs.net/api/response#responseredirecturl-alt, we can see: **response.redirect(url, [alt])** ``` Performs a [302] redirect to url. The string "back" is specially provided for Referrer support, using alt or "/" when Referrer does not exist. ctx.redirect('back'); ctx.redirect('back', '/index.html'); ctx.redirect('/login'); ctx.redirect('http://google.com'); ``` however, the "back" method is insecure: - https://github.com/koajs/koa/blob/master/lib/response.js#L322 ``` back (alt) { const url = this.ctx.get('Referrer') || alt || '/' this.redirect(url) }, ``` Referrer Header is User-Controlled. ## PoC **there is a demo for POC:** ``` const Koa = require('koa') const serve = require('koa-static') const Router = require('@koa/router') const path = require('path') const app = new Koa() const router = new Router() // Serve static files from the public directory app.use(serve(path.join(__dirname, 'public'))) // Define routes router.get('/test', ctx => { ctx.redirect('back', '/index1.html') }) router.get('/test2', ctx => { ctx.redirect('back') }) router.get('/', ctx => { ctx.body = 'Welcome to the home page! Try accessing /test, /test2' }) app.use(router.routes()) app.use(router.allowedMethods()) const port = 3000 app.listen(port, () => { console.log(`Server running at http://localhost:${port}`) }) ``` **Proof Of Concept** ``` GET /test HTTP/1.1 Host: 127.0.0.1:3000 Referer: http://www.baidu.com Connection: close GET /test2 HTTP/1.1 Host: 127.0.0.1:3000 Referer: http://www.baidu.com Connection: close ``` ![image](https://github.com/user-attachments/assets/03d1e61b-df97-4b42-a0c4-437bd17144db) ![image](https://github.com/user-attachments/assets/f4e076e0-3853-4b7a-b4c0-bddf5b67631a) ## Impact https://learn.snyk.io/lesson/open-redirect/

CVE-2025-8129 Affected Koa Versions

2 component(s)
Fixed Versions:
2.16.23.0.1
Product / Package Ecosystem Affected Versions Fixed Version
koa
npm
≥ 2.0.0
< 2.16.2
2.16.2
koa
npm
≥ 3.0.0-alpha.0
< 3.0.1
3.0.1

References

Frequently Asked Questions

What is CVE-2025-8129?
CVE-2025-8129 is a security vulnerability in Koa involving Koa Open Redirect via Referrer Header (User-Controlled) under CWE-601: URL Redirection to Untrusted Site ('Open Redirect').
Which Koa versions are affected?
Affected versions include releases prior to 2.16.2, 3.0.1 across affected packages: koa.
What version fixes CVE-2025-8129?
Upgrading to 2.16.2, 3.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is koa affected?
Yes, koa is affected in releases prior to 2.16.2, 3.0.1. Upgrade your dependency to 2.16.2, 3.0.1 or later.
What is the CVSS score of CVE-2025-8129?
CVE-2025-8129 has a CVSS v3.1 base score of 3.5 (LOW) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2025-8129?
CVE-2025-8129 is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect') (The web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect.).
How can I check npm dependencies for CVE-2025-8129?
Run the dependency tree command: 'npm ls koa'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-jgmv-j7ww-jx2x",
  "modified" : "2025-07-30T14:14:46Z",
  "published" : "2025-07-29T19:11:25Z",
  "aliases" : [ "CVE-2025-8129" ],
  "summary" : "Koa Open Redirect via Referrer Header (User-Controlled)",
  "details" : "## Summary\nIn the latest version of Koa, the back method used for redirect operations adopts an insecure implementation, which uses the user-controllable referrer header as the redirect target.\n\n## Details\non the API document https://www.koajs.net/api/response#responseredirecturl-alt, we can see:\n\n**response.redirect(url, [alt])**\n```\nPerforms a [302] redirect to url.\nThe string \"back\" is specially provided for Referrer support, using alt or \"/\" when Referrer does not exist.\n\nctx.redirect('back');\nctx.redirect('back', '/index.html');\nctx.redirect('/login');\nctx.redirect('http://google.com');\n\n```\nhowever, the \"back\" method is insecure:\n\n- https://github.com/koajs/koa/blob/master/lib/response.js#L322\n```\n  back (alt) {\n    const url = this.ctx.get('Referrer') || alt || '/'\n    this.redirect(url)\n  },\n```\nReferrer Header is User-Controlled.\n\n\n## PoC\n\n**there is a demo for POC:**\n```\nconst Koa = require('koa')\nconst serve = require('koa-static')\nconst Router = require('@koa/router')\nconst path = require('path')\n\nconst app = new Koa()\nconst router = new Router()\n\n// Serve static files from the public directory\napp.use(serve(path.join(__dirname, 'public')))\n\n// Define routes\nrouter.get('/test', ctx => {\n  ctx.redirect('back', '/index1.html')\n})\n\nrouter.get('/test2', ctx => {\n  ctx.redirect('back')\n})\n\nrouter.get('/', ctx => {\n  ctx.body = 'Welcome to the home page! Try accessing /test, /test2'\n})\n\napp.use(router.routes())\napp.use(router.allowedMethods())\n\nconst port = 3000\napp.listen(port, () => {\n  console.log(`Server running at http://localhost:${port}`)\n}) \n```\n**Proof Of Concept**\n```\nGET /test HTTP/1.1\nHost: 127.0.0.1:3000\nReferer: http://www.baidu.com\nConnection: close\n\n\nGET /test2 HTTP/1.1\nHost: 127.0.0.1:3000\nReferer: http://www.baidu.com\nConnection: close\n```\n![image](https://github.com/user-attachments/assets/03d1e61b-df97-4b42-a0c4-437bd17144db)\n\n![image](https://github.com/user-attachments/assets/f4e076e0-3853-4b7a-b4c0-bddf5b67631a)\n\n\n## Impact\nhttps://learn.snyk.io/lesson/open-redirect/",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:N/I:L/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "koa"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.16.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "koa"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.0.0-alpha.0"
      }, {
        "fixed" : "3.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/koajs/koa/security/advisories/GHSA-jgmv-j7ww-jx2x"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-54420"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/koajs/koa/issues/1892"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/koajs/koa/issues/1892#issue-3213028583"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/koajs/koa/commit/422c551c63d00f24e2bbbdf492f262a5935bb1f0"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/koajs/koa"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?ctiid.317514"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?id.317514"
  }, {
    "type" : "WEB",
    "url" : "https://vuldb.com/?submit.619741"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-601" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-07-29T19:11:25Z",
    "nvd_published_at" : "2025-07-29T17:15:33Z"
  }
}