CVE-2023-50710: Hono Named Path Parameters Can Be Vulnerability

MODERATE
Advisory Identifier: GHSA-f6gv-hh8j-q8vq
CVSS 4.2
CWE-94
Published
Advisory Summary

CVE-2023-50710 is a MODERATE (CVSS 4.2) named path parameters can be vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Hono libraries in the npm ecosystem. The issue involves named path parameters can be overridden in trierouter. Remediation is available by upgrading affected packages to version 3.11.7.

CVE-2023-50710 at a Glance

CVE Identifier CVE-2023-50710
GHSA Identifier GHSA-f6gv-hh8j-q8vq
Severity MODERATE
CVSS v3.1 Base Score 4.2
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Hono
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 4.2

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

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

How to Fix CVE-2023-50710

To remediate this vulnerability, upgrade all affected Hono dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

hono fixed: 3.11.7
npm install hono@3.11.7
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 hono

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2023-50710, inspect your project dependencies using npm:

npm ls hono

Analyze the terminal output to locate any version of Hono in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.11.7), your application is affected.

Note: The npm ls hono 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-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Hono, 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

### Impact The clients may override named path parameter values from previous requests if the application is using TrieRouter. So, there is a risk that a privileged user may use unintended parameters when deleting REST API resources. TrieRouter is used either explicitly or when the application matches a pattern that is not supported by the default RegExpRouter. The code to reproduce it. The server side application: ```ts import { Hono } from 'hono' import { TrieRouter } from 'hono/router/trie-router' const wait = async (ms: number) => { return new Promise((resolve) => { setTimeout(resolve, ms) }) } const app = new Hono({ router: new TrieRouter() }) app.use('*', async (c, next) => { await wait(Math.random() * 200) return next() }) app.get('/modules/:id/versions/:version', async (c) => { const id = c.req.param('id') const version = c.req.param('version') console.log('path', c.req.path) console.log('version', version) return c.json({ id, version, }) }) export default app ``` The client code which makes requests to the server application: ```ts const examples = [ 'http://localhost:8787/modules/first/versions/first', 'http://localhost:8787/modules/second/versions/second', 'http://localhost:8787/modules/third/versions/third', ] const test = () => { for (const example of examples) { fetch(example) .then((response) => response.json()) .then((data) => { const splitted = example.split('/') const expected = splitted[splitted.length - 1] if (expected !== data.version) { console.error(`Error: exprected ${expected} but got ${data.version} - url was ${example}`) } }) } } test() ``` The results: ```txt Error: exprected second but got third - url was http://localhost:8787/modules/second/versions/second Error: exprected first but got third - url was http://localhost:8787/modules/first/versions/first ``` ### Patches "v3.11.7" includes the change to fix this issue. ### Workarounds Don't use TrieRouter directly. ```ts // DON'T USE TrieRouter import { TrieRouter } from 'hono/router/trie-router' const app = new Hono({ router: new TrieRouter() }) ``` ### References Router options on the Hono website: https://hono.dev/api/hono#router-option

CVE-2023-50710 Affected Hono Versions

1 component(s)
Fixed Versions:
3.11.7
Product / Package Ecosystem Affected Versions Fixed Version
hono
npm
< 3.11.7
3.11.7

References

Frequently Asked Questions

What is CVE-2023-50710?
CVE-2023-50710 is a security vulnerability in Hono involving Named path parameters can be overridden in TrieRouter under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Hono versions are affected?
Affected versions include releases prior to 3.11.7 across affected packages: hono.
What version fixes CVE-2023-50710?
Upgrading to 3.11.7 (or the latest patched release for your respective branch) resolves the vulnerability.
Is hono affected?
Yes, hono is affected in releases prior to 3.11.7. Upgrade your dependency to 3.11.7 or later.
What is the CVSS score of CVE-2023-50710?
CVE-2023-50710 has a CVSS v3.1 base score of 4.2 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:L/A:L.
What CWE is associated with CVE-2023-50710?
CVE-2023-50710 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check npm dependencies for CVE-2023-50710?
Run the dependency tree command: 'npm ls hono'. 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-f6gv-hh8j-q8vq",
  "modified" : "2023-12-15T02:45:54Z",
  "published" : "2023-12-15T02:45:54Z",
  "aliases" : [ "CVE-2023-50710" ],
  "summary" : "Named path parameters can be overridden in TrieRouter",
  "details" : "### Impact\n\nThe clients may override named path parameter values from previous requests if the application is using TrieRouter. So, there is a risk that a privileged user may use unintended parameters when deleting REST API resources.\n\nTrieRouter is used either explicitly or when the application matches a pattern that is not supported by the default RegExpRouter.\n\nThe code to reproduce it. The server side application:\n\n```ts\nimport { Hono } from 'hono'\nimport { TrieRouter } from 'hono/router/trie-router'\n\nconst wait = async (ms: number) => {\n  return new Promise((resolve) => {\n    setTimeout(resolve, ms)\n  })\n}\n\nconst app = new Hono({ router: new TrieRouter() })\n\napp.use('*', async (c, next) => {\n  await wait(Math.random() * 200)\n  return next()\n})\n\napp.get('/modules/:id/versions/:version', async (c) => {\n  const id = c.req.param('id')\n  const version = c.req.param('version')\n\n  console.log('path', c.req.path)\n  console.log('version', version)\n\n  return c.json({\n    id,\n    version,\n  })\n})\n\nexport default app\n```\n\nThe client code which makes requests to the server application:\n\n```ts\nconst examples = [\n  'http://localhost:8787/modules/first/versions/first',\n  'http://localhost:8787/modules/second/versions/second',\n  'http://localhost:8787/modules/third/versions/third',\n]\n\nconst test = () => {\n  for (const example of examples) {\n    fetch(example)\n      .then((response) => response.json())\n      .then((data) => {\n        const splitted = example.split('/')\n        const expected = splitted[splitted.length - 1]\n\n        if (expected !== data.version) {\n          console.error(`Error: exprected ${expected} but got ${data.version} - url was ${example}`)\n        }\n      })\n  }\n}\n\ntest()\n```\n\nThe results:\n\n```txt\nError: exprected second but got third - url was http://localhost:8787/modules/second/versions/second\nError: exprected first but got third - url was http://localhost:8787/modules/first/versions/first\n```\n\n### Patches\n\n\"v3.11.7\" includes the change to fix this issue.\n\n### Workarounds\n\nDon't use TrieRouter directly.\n\n```ts\n// DON'T USE TrieRouter\nimport { TrieRouter } from 'hono/router/trie-router'\nconst app = new Hono({ router: new TrieRouter() })\n```\n\n### References\n\nRouter options on the Hono website: https://hono.dev/api/hono#router-option",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "hono"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.11.7"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/honojs/hono/security/advisories/GHSA-f6gv-hh8j-q8vq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-50710"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/honojs/hono/commit/8e2b6b08518998783f66d31db4f21b1b1eecc4c8"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/honojs/hono"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/honojs/hono/releases/tag/v3.11.7"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-12-15T02:45:54Z",
    "nvd_published_at" : "2023-12-14T18:15:45Z"
  }
}