Hono 4.13.21 tightens security: strict signature checks in hono/jwt and host protection in hono/clientBrief · digest for November 24
Brief≈ 2 min

Hono 4.13.21 tightens security: strict signature checks in hono/jwt and host protection in hono/client

The same JWT used to pass verification under different string variants—you could just append = to the signature or flip unused trailing bits. Token blacklists and raw-string caches missed those variants. In Hono 4.13.21, hono/jwt re-encodes the signature and accepts only canonical Base64URL without =, whitespace, or extra bits.

The second fix lands in hono/client. With a relative baseURL like '/', a path parameter such as /evil.example produced //evil.example. Browsers and fetch treat a double slash as a protocol-relative host change, sending the request and its headers to an attacker's domain. Leading slashes now collapse, while slashes inside parameters still work as before.

import { verify } from 'hono/jwt'
import { hc } from 'hono/client'
import type { AppType } from './server'

// Signatures with '=' padding or extra bits are now rejected
const payload = await verify(token, secret, 'HS256')

// Relative baseURL: path parameter will not redirect to //host
const client = hc<AppType>('/')
const res = await client.items[':id'].$get({
  param: { id: userInput },
})

Upgrading is simple: npm install hono@4.13.21. Standard RFC 7515 JWTs keep working untouched, and only custom test signatures with = padding will break. Note that hono/client still doesn't run encodeURIComponent on parameters, so you still need to validate user input.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 5