CVE-2023-50710
JSON

4.2medium

Hono's named path parameters can be overridden in TrieRouter

Severity
4.2medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.64% (higher than 51% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-f6gv-hh8j-q8vq

Description

Hono is a web framework written in TypeScript. Prior to version 3.11.7, 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. Version 3.11.7 includes the change to fix this issue. As a workaround, avoid using TrieRouter directly.

Affected

Product or packageVersionsReported by
honojs hono< 3.11.7CVE List
hono (npm)before 3.11.7GitHub Advisory Database
hono honobefore 3.11.7NVD

All scores

GitHub_M4.2medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:L/A:L
GitHub4.2medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:N/I:L/A:L
NVD4.3medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N

Classification

What each source says

CVE List

Hono is a web framework written in TypeScript. Prior to version 3.11.7, 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. Version 3.11.7 includes the change to fix this issue. As a workaround, avoid using TrieRouter directly.

GitHub Advisory Database
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:

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:

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:

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.

// 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

NVD (es)

Hono es un framework web escrito en TypeScript. Antes de la versión 3.11.7, los clientes pueden anular los valores de los parámetros de ruta con nombre de solicitudes anteriores si la aplicación utiliza TrieRouter. Por lo tanto, existe el riesgo de que un usuario privilegiado utilice parámetros no deseados al eliminar recursos de la API REST. TrieRouter se usa explícitamente o cuando la aplicación coincide con un patrón que no es compatible con el RegExpRouter predeterminado. La versión 3.11.7 incluye el cambio para solucionar este problema. Como workaround, evite utilizar TrieRouter directamente.

References

Sources

SourceRecordLicence
CVE ListCVE-2023-50710 changed 2024-08-02CVE Terms of Use
GitHub Advisory DatabaseGHSA-f6gv-hh8j-q8vq changed 2026-09-10CC-BY-4.0
NVDCVE-2023-50710 changed 2026-06-17Public domain