|
| 1 | +From c0a8f88b3e611b0a2533319636115226b6c3ee35 Mon Sep 17 00:00:00 2001 |
| 2 | +From: akhila-guruju < [email protected]> |
| 3 | +Date: Thu, 22 May 2025 12:13:45 +0000 |
| 4 | +Subject: [PATCH] Address CVE-2024-51744 |
| 5 | + |
| 6 | +Upstream Patch reference: https://github.com/golang-jwt/jwt/commit/7b1c1c00a171c6c79bbdb40e4ce7d197060c1c2c |
| 7 | + |
| 8 | +--- |
| 9 | + vendor/github.com/golang-jwt/jwt/v4/parser.go | 23 ++++++++----------- |
| 10 | + 1 file changed, 10 insertions(+), 13 deletions(-) |
| 11 | + |
| 12 | +diff --git a/vendor/github.com/golang-jwt/jwt/v4/parser.go b/vendor/github.com/golang-jwt/jwt/v4/parser.go |
| 13 | +index 9484f28..d6e75db 100644 |
| 14 | +--- a/vendor/github.com/golang-jwt/jwt/v4/parser.go |
| 15 | ++++ b/vendor/github.com/golang-jwt/jwt/v4/parser.go |
| 16 | +@@ -80,12 +80,17 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf |
| 17 | + return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable} |
| 18 | + } |
| 19 | + |
| 20 | ++ // Perform validation |
| 21 | ++ token.Signature = parts[2] |
| 22 | ++ if err := token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil { |
| 23 | ++ return token, &ValidationError{Inner: err, Errors: ValidationErrorSignatureInvalid} |
| 24 | ++ } |
| 25 | ++ |
| 26 | + vErr := &ValidationError{} |
| 27 | + |
| 28 | + // Validate Claims |
| 29 | + if !p.SkipClaimsValidation { |
| 30 | + if err := token.Claims.Valid(); err != nil { |
| 31 | +- |
| 32 | + // If the Claims Valid returned an error, check if it is a validation error, |
| 33 | + // If it was another error type, create a ValidationError with a generic ClaimsInvalid flag set |
| 34 | + if e, ok := err.(*ValidationError); !ok { |
| 35 | +@@ -93,22 +98,14 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf |
| 36 | + } else { |
| 37 | + vErr = e |
| 38 | + } |
| 39 | ++ return token, vErr |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | +- // Perform validation |
| 44 | +- token.Signature = parts[2] |
| 45 | +- if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil { |
| 46 | +- vErr.Inner = err |
| 47 | +- vErr.Errors |= ValidationErrorSignatureInvalid |
| 48 | +- } |
| 49 | +- |
| 50 | +- if vErr.valid() { |
| 51 | +- token.Valid = true |
| 52 | +- return token, nil |
| 53 | +- } |
| 54 | ++ // No errors so far, token is valid. |
| 55 | ++ token.Valid = true |
| 56 | + |
| 57 | +- return token, vErr |
| 58 | ++ return token, nil |
| 59 | + } |
| 60 | + |
| 61 | + // ParseUnverified parses the token but doesn't validate the signature. |
| 62 | +-- |
| 63 | +2.45.2 |
| 64 | + |
0 commit comments