---
id: "GHSA-h7mg-cq63-vhpq"
page: "https://infrastack.ai/live/GHSA-h7mg-cq63-vhpq"
kind: "vulnerability"
aliases: ["GHSA-h7mg-cq63-vhpq"]
title: "RegExpRouter skips wildcard middleware for certain route patterns and for paths with an encoded line terminator"
severity: "medium"
cvss: 5.3
epss: null
exploited: false
status: "open"
category: "package"
products: [{"name": "hono", "fixed": ["4.13.16"], "affected": ">= 4.1.4, <= 4.13.15", "ecosystem": "npm"}]
ecosystems: ["npm"]
tags: ["bun", "cloudflare-workers", "cwe-863", "deno", "hono", "node", "package"]
not_affected_if: ["default-config-not-used", "no-wildcard-auth-middleware", "trierouter-in-use"]
published_at: "2026-11-01T02:31:34+00:00"
first_seen_at: "2026-11-09T22:53:17+00:00"
updated_at: "2026-11-09T22:56:36+00:00"
sources: [{"source": "ghsa-repo", "url": "https://github.com/honojs/hono/security/advisories/GHSA-h7mg-cq63-vhpq", "first_seen_at": "2026-11-09T22:53:17+00:00"}]
exploit_sources: []
---

# RegExpRouter skips wildcard middleware for certain route patterns and for paths with an encoded line terminator

Link for people: https://infrastack.ai/live/GHSA-h7mg-cq63-vhpq (this .md is for agents)

Hono's RegExpRouter, the default router for most applications, sometimes fails to apply wildcard middleware to matching routes and to paths containing an encoded line terminator. An unauthenticated client can reach a route handler or the not-found handler without the authentication or authorization middleware registered for it.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- npm:hono affected >= 4.1.4, <= 4.13.15 fixed 4.13.16

## How to check

- Check the installed version with `npm ls hono` and confirm whether it is between `4.1.4` and `4.13.15`.
- Look for wildcard middleware (such as `app.use('/admin/*', ...)`) that handles authentication or authorization, and for routes registered with explicit patterns like `:tenant{[^/]+}`.
- Confirm whether the app uses the default `SmartRouter` or RegExpRouter directly.

## Fix

- `hono` `4.13.16`
- Workaround named by the advisory: `new Hono({ router: new TrieRouter() })`

## Timeline

- 2026-11-09T22:53:17+00:00 ghsa-repo https://github.com/honojs/hono/security/advisories/GHSA-h7mg-cq63-vhpq

## Documents

- [advisory] Maintainer's advisory: github.com https://github.com/honojs/hono/security/advisories/GHSA-h7mg-cq63-vhpq

## From the sources

### Summary

RegExpRouter, which the default `SmartRouter` selects for most applications, skipped wildcard middleware in three cases, so a route handler ran without the middleware registered for it:

1. Middleware whose parameter is written with the explicit default pattern, such as `/api/:tenant{[^/]+}/admin/*`, was not applied to a route written as `/api/:tenant/admin/:id`. (since 4.13.0)
2. Middleware on `/admin/*` was not applied to a route registered on `/admin*` for paths under `/admin/`. (since 4.1.4)
3. For a path with an encoded line terminator (`%0A`, `%0D`, `%E2%80%A8`, `%E2%80%A9`), no wildcard pattern matched, so the request reached the not-found handler without any wildcard middleware. (since 4.4.0)

TrieRouter, LinearRouter and PatternRouter apply the middleware in all three cases.

### Details

RegExpRouter decides at registration time which wildcard middleware covers which route. In cases 1 and 2 it treated patterns that match the same requests as different ones. In case 3 the compiled wildcard did not match line terminators.

The fix derives the coverage from the structure of the registered paths and lets wildcards match line terminators. It also corrects other differences from the other routers (a wildcard in the middle of a path with parameters, duplicate middleware, middleware on static routes), and rejects custom patterns that can match the empty string, such as `{[0-9]*}`, with `UnsupportedPathError`. `PreparedRegExpRouter` data must be regenerated.

### Impact

An unauthenticated client can reach a route handler, or the not-found handler, without the authentication or authorization middleware registered on a wildcard path.

This affects applications that use RegExpRouter, directly or through the default `SmartRouter`, and rely on wildcard middleware for authentication or authorization.

### Workarounds

Use `new Hono({ router: new TrieRouter() })`.

---

_Free to read, with fair use of about 60 pages a minute. For higher limits or API access: sales@infrastack.ai_
