Skip to content
Discussion options

You must be logged in to vote

@merthanmerter this is intentional, not a docs bug. it was a security fix in v4.11.4 to prevent JWT algorithm confusion attacks (GHSA-f67f-6cw9-8mq4).

the alg param in verify() went from optional to required in src/utils/jwt/jwt.ts. without it, an attacker could forge tokens by exploiting the default HS256 fallback with asymmetric keys. sign() wasn't changed (defaults to HS256), which is why only verify broke.

fix:

import { verify } from 'hono/jwt'

const payload = await verify(token, secret, 'HS256')

// or with options:
const payload = await verify(token, secret, {
  alg: 'HS256',
  iss: 'my-app',
})

the current docs page already shows alg as required. you were probably seeing cached ty…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by merthanmerter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants