Hono v4.13.23: Three Vulnerabilities in TrieRouter, except(), and Bun URL ParsingNote · digest for November 28
Conceptual security filter for the Hono router blocking Prototype Pollution attacks and normalizing request paths
Note3 sections≈ 4 min

Hono v4.13.23: Three Vulnerabilities in TrieRouter, except(), and Bun URL Parsing

Routing looks rock-solid locally: auth sits on /api/*, public endpoints are excluded, and Nginx or Caddy sits out front. Yet Hono v4.13.23, released on November 26, 2026, patched three Medium-severity vulnerabilities in that exact setup. Normal tests missed them because they triggered on the __proto__ method or HTTP/1.0 requests without a Host header.

The __proto__ method and process crashes in TrieRouter

The first bug (GHSA-656w-x92q-369m, CVSS 5.9) affected 4.8.0–4.13.22, older 3.11.7–4.1.1, and 5.0.0-rc.0–5.0.0-rc.1. The built-in TrieRouter (prefix-tree router) stored method handlers in a plain JS object { [method]: ... }, which inherits from Object.prototype.

If a server accepts arbitrary HTTP methods (Node.js over HTTP/2 or hono/method-override), a request with method constructor, toString, hasOwnProperty, or __proto__ resolved a prototype property instead of undefined. For __proto__, the router grabbed Object.prototype itself and wrote an enumerable property onto it—classic prototype pollution. After one such request, that extra field leaked into every object in the process, crashing the server on response headers until restart.

In src/router/trie-router/node.ts, the method map now uses a null-prototype object via createNullObject() (Object.create(null)):

// Before: plain object inherits Object.prototype
curNode.#methods.push({ [method]: { handler, ... } })

// After: null-prototype object ignores __proto__
const methodMap: Record<string, HandlerSet<T>> = createNullObject()
methodMap[method] = { handler, possibleKeys: [...possibleKeys], score }
curNode.#methods.push(methodMap)

Looking up __proto__ now returns undefined, so a single request can no longer crash a Node.js process running HTTP/2 or hono/method-override.

Regex trap in except() across every router

The second flaw (GHSA-586x-c76g-h528, CVSS 5.3, versions 4.5.0–4.13.22 and 5.0.0-rc.0–5.0.0-rc.1) hits even apps using SmartRouter or RegExpRouter. Why? Because except() from hono/combine always uses TrieRouter internally.

The bug lived in constrained route parameters—route segments with a regex like /api/:name{login|health}. getPattern() in src/utils/url.ts wrapped the pattern in ^${match[2]}$ without parentheses, producing /^login|health$/. Since | has lower precedence than anchors, ^ bound only to login and $ bound only to health. As a result, /api/loginX and /api/xhealth also matched the exception and bypassed authMiddleware.

// Before the fix, authMiddleware was skipped for /api/loginX and /api/xhealth
app.use('/api/*', except('/api/:name{login|health}', authMiddleware))
app.get('/api/:name', (c) => c.text(c.req.param('name')))

// Fix in src/utils/url.ts: non-capturing group instead of bare anchors
new RegExp(`^(?:${match[2]})$`)

The same (?:...) group was added to the lookahead branch ^(?:${match[2]})(?=/${next}). Alternatives inside curly braces now stay strictly within their segment.

Dropping the first path segment in getPath() on Bun

The third bug (GHSA-mhwf-w6q6-q58w, CVSS 5.3, versions before 4.13.23 and 5.0.0-rc.0–5.0.0-rc.1) affects Bun behind a reverse proxy (Nginx, Envoy, Caddy) using path-based access rules where /public/* is open and /admin/* is restricted.

getPath(request) looked up the path via url.indexOf('/', url.indexOf(':') + 4), expecting a full URL with a scheme. However, on HTTP/1.0 without Host or with an empty Host, Bun puts a bare path like /public/admin/secret into request.url. With no colon present, indexOf(':') + 4 evaluates to 3, so searching for / from index 3 strips /public. The proxy allows /public/admin/secret, while Hono routes it to /admin/secret—pure path confusion.

// Fix in src/utils/url.ts: check the first character code ('/' === 47)
export const getPath = (request: Request): string => {
  const url = request.url
  const start =
    url.charCodeAt(0) === 47
      ? 0
      : url.indexOf('/', url.indexOf(':') + 4)
}

Checking the first character closes the bypass with zero extra allocations and even works on paths containing colons, like /a:b/admin/secret.

What to check when upgrading

  • Update hono to 4.13.23: the entire v4.13.22...v4.13.23 diff is 10 lines of code and 74 lines of tests, with no breaking changes.
  • Audit uses of hono/method-override, except() with {a|b}, and Bun behind proxies without Host.
  • On 5.0.0-rc.0–5.0.0-rc.1, wait for a newer RC: these builds are affected, and the 5.0 RC patch isn't out yet.
Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 5