Ad
 
Learn More

Middleware that never runs is the Important line in Hono

Hono v4.13.16 fixes five advisories, and four let a request reach your handler without the middleware you thought guarded it: mount() path forwarding, RegExpRouter wildcard gaps, validator('form') and csrf(). Some route shapes now throw, so boot it in staging first.

Written by Watch Changelog Team

•2 min read

Middleware that never runs is the Important line in Hono

Hono shipped v4.13.16 on November 1, and we flagged it as Important on Hono Releases. It fixes five advisories, and four of them share one shape: a request reaches your handler without passing through the middleware you thought guarded it. If your auth, rate limiting or tenant checks live in Hono middleware, this is the release to read closely.

The bypass fixes:

  • GHSA-4m76-xfj5-7975: mount() in hono/mount and app.mount() could forward a path that skipped middleware scoped inside the mount prefix. A dynamic prefix such as /api/:tenant/* was stripped by the length of the route pattern, and the forwarded path was re-normalized by the URL parser, so a decoded backslash became a slash and .. collapsed.
  • GHSA-h7mg-cq63-vhpq: RegExpRouter, which the default SmartRouter uses, did not apply wildcard middleware in three cases: a parameter written as {[^/]+} in the middleware path only, a /prefix* route next to /prefix/* middleware, and a path with an encoded line terminator.
  • GHSA-4h7h-rv7c-7m2v: validator('form') did not recognize a multipart/form-data request with an extra parameter such as charset. The validator saw an empty object while the handler could still read every field.
  • GHSA-46wx-v44x-9hh2: csrf() did not check POST requests sent by Chromium's a ping hyperlink auditing, which use the content type text/ping, against Origin and Sec-Fetch-Site.

The fifth, GHSA-3gg2-335m-rxc6, is HTML injection in the css helper: a closing style tag split between the template and a value, or between two values, was not escaped. That one matters if you pass untrusted values into css.

Here is the part that can break a deploy. Some of the fixes reject route shapes that used to work. With mount(), routes such as /assets* and duplicate parameter names now throw. In RegExpRouter, custom patterns that can match the empty string, such as {[0-9]*}, now throw UnsupportedPathError. And if you ship PreparedRegExpRouter data, the notes say to regenerate it. The same release also makes the JWT helper reject a signature segment outside the base64url alphabet and a header with crit, so check any tokens your own tooling mints.

What I would do: upgrade to v4.13.16 now if you use mount() with path-scoped middleware, wildcard middleware on the default router, validator('form'), csrf(), or css with user input. Boot the app in staging first so any route that now throws shows up there, regenerate PreparedRegExpRouter data if you use it, and add a test that hits a guarded route through a mounted sub-app with an encoded path. The rest of the day's flagged changes are on /sources/important.

Official notes: Hono v4.13.16.