You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JwtToken accepts segments that are not base64url: embedded spaces ("eyJh bGci OiJI UzI1 NiJ9.…"), = padding and +// all validate #329
JwtToken's XML doc says it is "three '.'-separated base64url segments" (Semantics.Strings.Identifiers/JwtToken.cs:8), and the attribute says the header and payload "base64url-decode". IsJwtTokenAttribute.DecodesToJsonObject (Semantics.Strings.Identifiers/IsJwtTokenAttribute.cs:52-72) actually does the following:
It maps -→+ and _→/, but does not reject +, / or = already in the segment, all of which are outside the base64url alphabet (RFC 7515 §2 also forbids padding).
It pads based on segment.Length % 4 and then calls Convert.FromBase64String, which silently skips whitespace. The length check counts the whitespace, so a segment with embedded spaces decodes whenever the spaces happen to make the length work.
JwtToken does no canonicalization, so the malformed text is stored verbatim, and every downstream JWT library will reject it.
This is the same root cause as #316 ([IsBase64] and whitespace), but in a separate validator in the Identifiers package, so fixing #316 does not fix it.
Suggested fix / acceptance criteria
Before decoding, require each of the header and payload segments to match ^[A-Za-z0-9_-]+$ (no =, +, /, or whitespace), and reject a segment whose length is 1 mod 4. The signature segment should match ^[A-Za-z0-9_-]*$ (it may be empty, as documented).
Tests: both accepted strings above are rejected, and the existing valid and alg=none vectors still pass.
Priority: Medium. A semantic type exists to guarantee a well-formed value, and this one accepts tokens every JWT library will reject. The failure shows up later, far from its cause. The fix is a small alphabet check before decoding.
Area / suggested assignment:IsJwtTokenAttribute.DecodesToJsonObject (Semantics.Strings.Identifiers/IsJwtTokenAttribute.cs:52-72).
Activity
matt-edmondson commentedon Sep 29, 2026
Triage
IsJwtTokenAttribute.DecodesToJsonObject(Semantics.Strings.Identifiers/IsJwtTokenAttribute.cs:52-72).[IsBase64]accepts values containing whitespace whenever the total length is a multiple of 4 #316 ([IsBase64]accepts whitespace) in a separate validator, so fix them together if convenient, perhaps with a shared strict base64url check.Generated by Claude Code