Skip to content

Commit 681b4d8

Browse files
thatnealpatelgopherbot
authored andcommitted
jws: split token into fixed number of parts
Thanks to 'jub0bs' for reporting this issue. Fixes #71490 Fixes CVE-2025-22868 Change-Id: I2552731f46d4907f29aafe7863c558387b6bd6e2 Reviewed-on: https://go-review.googlesource.com/c/oauth2/+/652155 Auto-Submit: Gopher Robot <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Roland Shoemaker <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 3f78298 commit 681b4d8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

jws/jws.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ func Encode(header *Header, c *ClaimSet, key *rsa.PrivateKey) (string, error) {
165165
// Verify tests whether the provided JWT token's signature was produced by the private key
166166
// associated with the supplied public key.
167167
func Verify(token string, key *rsa.PublicKey) error {
168-
parts := strings.Split(token, ".")
169-
if len(parts) != 3 {
168+
if strings.Count(token, ".") != 2 {
170169
return errors.New("jws: invalid token received, token must have 3 parts")
171170
}
172171

172+
parts := strings.SplitN(token, ".", 3)
173173
signedContent := parts[0] + "." + parts[1]
174174
signatureString, err := base64.RawURLEncoding.DecodeString(parts[2])
175175
if err != nil {

0 commit comments

Comments
 (0)