fix(isJWT): reject tokens with an empty header or payload segment - #2875
fix(isJWT): reject tokens with an empty header or payload segment#2875spokodev wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2875 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 114 114
Lines 2599 2601 +2
Branches 658 659 +1
=========================================
+ Hits 2599 2601 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
nrps9909
left a comment
There was a problem hiding this comment.
Reviewed 66622ba31e8241eb36a12b6390112464416c9e28.
Confirmed the three empty-header/payload examples are accepted on base a79ff98 and rejected on this head. I also checked the compatibility boundary explicitly: eyJhbGciOiJub25lIn0.e30. (an alg: none header, an empty JSON claims object, and an empty signature) remains accepted, consistent with RFC 7519 section 6. Two/four segments remain rejected, and non-string input still throws.
The same seven-case probe passed against source, the generated Node and ES module entry points, and both browser bundles (35 checks, plus non-string checks for each form). npm test also passed: all builds, lint, 323 tests, and 100% statements/functions/lines. The current upstream Node 8–24 checks are green.
No blocking findings for this structural empty-segment fix.
isJWTaccepts tokens whose header or payload segment is empty, e.g.isJWT('..'),isJWT('.<payload>.<sig>')andisJWT('<header>..<sig>')all returntrue.Per RFC 7519 / RFC 7515 the JOSE header (a JSON object that must contain
alg) and the payload are base64url encodings of non-empty JSON, so neither can be empty; only the signature may be empty (unsecured JWS,alg: none). The empty segments slip through today becauseisBase64('')returnstrue.This adds a guard requiring the header and payload segments to be non-empty, leaving the empty-signature (
<header>.<payload>.) case untouched. Tests added to the existinginvalidset.