REDHAT-BUG-2572863: Medium severity npm/hono vulnerability
Hono is a Web application framework that provides support for any JavaScript runtime. From 4.1.4 until 4.13.16, RegExpRouter can omit wildcard middleware in three version-specific cases: since 4.13.0, middleware using the explicit default parameter pattern in /api/:tenant{[^/]+}/admin/ is not applied to a route written as /api/:tenant/admin/:id; since 4.1.4, middleware on /admin/ is not applied to a route registered as /admin for paths under /admin/; and since 4.4.0, a request path containing an encoded line terminator can reach the not-found handler without wildcard middleware. The default SmartRouter selects RegExpRouter for most applications, and the router's registration-time coverage calculation treated the first two matching pattern pairs as different while its compiled wildcard did not match line terminators in the third case. An unauthenticated client can reach a route handler or the not-found handler without authentication or authorization middleware registered on the wildcard path. TrieRouter, LinearRouter, and PatternRouter apply the middleware in the three described cases. This issue is fixed in version 4.13.16.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Fixed in 4.13.16
Event History
Frequently Asked Questions
Which applications are realistically exposed to this middleware bypass?
Applications using Hono's default SmartRouter are commonly exposed because it selects RegExpRouter for most applications. Exposure depends on using wildcard authentication or authorization middleware together with one of the affected route-pattern cases.
What does an attacker need to exploit the issue?
An unauthenticated client only needs to request an affected route or, in the encoded-line-terminator case, a path that reaches the not-found handler. Successful exploitation requires that authentication or authorization middleware is registered on the wildcard path and omitted by RegExpRouter.
Which route configurations can bypass wildcard middleware?
The affected cases are /api/:tenant{[^/]+}/admin/* middleware with a /api/:tenant/admin/:id route since 4.13.0; /admin/* middleware with a /admin* route for paths beneath /admin/ since 4.1.4; and request paths containing an encoded line terminator since 4.4.0.
What can be done if upgrading is not immediately possible?
Use TrieRouter, LinearRouter, or PatternRouter instead of RegExpRouter, as these routers apply middleware in all three described cases. Review affected wildcard-protected routes and ensure authorization is also enforced by the individual route handlers where practical.
How can I determine whether an application is affected?
Check whether the application uses a Hono version from 4.1.4 through 4.13.16 and whether SmartRouter or RegExpRouter is in use. Then review route registration for the affected wildcard and route-pattern combinations, and test whether unauthenticated requests reach the route or not-found handler without the expected middleware.