fix: GHSA-cjw9-ghj4-fwxf CVE-2026-35041 ReDoS when using RegExp in allowed options#595
Merged
antoatta85 merged 8 commits intomasterfrom Apr 9, 2026
Merged
Conversation
…lowed options
|
@antoatta85 Could you fix this build? |
SociableSteve
requested changes
Apr 8, 2026
SociableSteve
approved these changes
Apr 9, 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: reject unsafe RegExp patterns in allowed* options to prevent ReDoS
Adds a construction-time check in
createVerifier()that throws aninvalidOptionerror if any of theallowedAud,allowedIss,allowedSub,allowedJti, orallowedNonceoptions contain aRegExpwith nested quantifiers (e.g.(a+)+,(a*)+,(\w+)+), which are the primary class of patterns susceptible to catastrophic backtracking (CWE-1333).The error is raised eagerly at verifier creation time, before any token is ever processed, so no attacker-controlled input can trigger the backtracking.
String values and safe RegExp patterns are unaffected.
Changes
src/verifier.js: addedunsafeRegExpPatternconstant andcheckForUnsafeRegExp()helper; called for all fiveallowed*options during option validation increateVerifier()test/verifier.spec.js: added 9 tests covering unsafe patterns across all five options, mixed arrays, various pattern variants, safe patterns that must not throw, and a normal verification round-trip with a safe RegExpFIXES #594