fix acceptance of unknown crit headers and comply with RFC 7515#591
Merged
SociableSteve merged 2 commits intomasterfrom Apr 7, 2026
Merged
fix acceptance of unknown crit headers and comply with RFC 7515#591SociableSteve merged 2 commits intomasterfrom
SociableSteve merged 2 commits intomasterfrom
Conversation
SociableSteve
approved these changes
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: validate
critheader parameter per RFC 7515 §4.1.11Problem
fast-jwt accepted tokens containing a
crit(Critical) header parameterwithout validating it, violating the MUST requirement in RFC 7515 §4.1.11:
This allowed an attacker to craft a token carrying security-semantic
extensions (e.g.
require-mfa,cnftoken binding) that would be silentlyaccepted by fast-jwt while being correctly rejected by compliant libraries
(e.g.
jose), creating a split-brain vulnerability in mixed-libraryenvironments.
This is the same class of issue as CVE-2025-59420 (Authlib, CVSS 7.5 HIGH).
Changes
src/error.js— new error codeFAST_JWT_INVALID_CRIT_HEADERsrc/verifier.js—validateCrit()enforces all RFC rules:crit: []crit(alg,typ,kid, …)critallowedCritHeadersoptioncritbut absent from the headersrc/index.d.ts—allowedCritHeaders?: string[]added toVerifierOptions;invalidCritHeaderadded toTOKEN_ERROR_CODEStest/verifier.spec.js— 8 new tests covering all validation pathsNew
createVerifieroptionDefaults to [] — any token carrying a crit header is rejected unless the
caller explicitly opts in.
Tokens with a crit header that were previously silently accepted will now be rejected. Tokens without crit are completely unaffected.
FIXES #590