Skip to content

Commit 72ede32

Browse files
[AUTO-CHERRYPICK] [LOW] Patch coredns to fix CVE-2024-51744 - branch main (#13463)
Co-authored-by: Archana Shettigar <v-shettigara@microsoft.com>
1 parent 57d8eaa commit 72ede32

2 files changed

Lines changed: 98 additions & 1 deletion

File tree

SPECS/coredns/CVE-2024-51744.patch

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
From 0b523a7953c247e7f68edd10c5a50b67f6038a37 Mon Sep 17 00:00:00 2001
2+
From: archana25-ms <v-shettigara@microsoft.com>
3+
Date: Mon, 24 Mar 2025 08:02:24 +0000
4+
Subject: [PATCH] Address CVE-2024-51744
5+
Upstream Patch Reference: https://github.com/golang-jwt/jwt/commit/7b1c1c00a171c6c79bbdb40e4ce7d197060c1c2c
6+
7+
---
8+
vendor/github.com/golang-jwt/jwt/v4/parser.go | 41 +++++++++----------
9+
1 file changed, 20 insertions(+), 21 deletions(-)
10+
11+
diff --git a/vendor/github.com/golang-jwt/jwt/v4/parser.go b/vendor/github.com/golang-jwt/jwt/v4/parser.go
12+
index c0a6f69..e6d0429 100644
13+
--- a/vendor/github.com/golang-jwt/jwt/v4/parser.go
14+
+++ b/vendor/github.com/golang-jwt/jwt/v4/parser.go
15+
@@ -36,19 +36,21 @@ func NewParser(options ...ParserOption) *Parser {
16+
return p
17+
}
18+
19+
-// Parse parses, validates, verifies the signature and returns the parsed token.
20+
-// keyFunc will receive the parsed token and should return the key for validating.
21+
+// Parse parses, validates, verifies the signature and returns the parsed token. keyFunc will
22+
+// receive the parsed token and should return the key for validating.
23+
func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) {
24+
return p.ParseWithClaims(tokenString, MapClaims{}, keyFunc)
25+
}
26+
27+
-// ParseWithClaims parses, validates, and verifies like Parse, but supplies a default object implementing the Claims
28+
-// interface. This provides default values which can be overridden and allows a caller to use their own type, rather
29+
-// than the default MapClaims implementation of Claims.
30+
+// ParseWithClaims parses, validates, and verifies like Parse, but supplies a default object
31+
+// implementing the Claims interface. This provides default values which can be overridden and
32+
+// allows a caller to use their own type, rather than the default MapClaims implementation of
33+
+// Claims.
34+
//
35+
-// Note: If you provide a custom claim implementation that embeds one of the standard claims (such as RegisteredClaims),
36+
-// make sure that a) you either embed a non-pointer version of the claims or b) if you are using a pointer, allocate the
37+
-// proper memory for it before passing in the overall claims, otherwise you might run into a panic.
38+
+// Note: If you provide a custom claim implementation that embeds one of the standard claims (such
39+
+// as RegisteredClaims), make sure that a) you either embed a non-pointer version of the claims or
40+
+// b) if you are using a pointer, allocate the proper memory for it before passing in the overall
41+
+// claims, otherwise you might run into a panic.
42+
func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyfunc) (*Token, error) {
43+
token, parts, err := p.ParseUnverified(tokenString, claims)
44+
if err != nil {
45+
@@ -85,12 +87,17 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
46+
return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable}
47+
}
48+
49+
+ // Perform validation
50+
+ token.Signature = parts[2]
51+
+ if err := token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil {
52+
+ return token, &ValidationError{Inner: err, Errors: ValidationErrorSignatureInvalid}
53+
+ }
54+
+
55+
vErr := &ValidationError{}
56+
57+
// Validate Claims
58+
if !p.SkipClaimsValidation {
59+
if err := token.Claims.Valid(); err != nil {
60+
-
61+
// If the Claims Valid returned an error, check if it is a validation error,
62+
// If it was another error type, create a ValidationError with a generic ClaimsInvalid flag set
63+
if e, ok := err.(*ValidationError); !ok {
64+
@@ -98,22 +105,14 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
65+
} else {
66+
vErr = e
67+
}
68+
+ return token, vErr
69+
}
70+
}
71+
72+
- // Perform validation
73+
- token.Signature = parts[2]
74+
- if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil {
75+
- vErr.Inner = err
76+
- vErr.Errors |= ValidationErrorSignatureInvalid
77+
- }
78+
-
79+
- if vErr.valid() {
80+
- token.Valid = true
81+
- return token, nil
82+
- }
83+
+ // No errors so far, token is valid.
84+
+ token.Valid = true
85+
86+
- return token, vErr
87+
+ return token, nil
88+
}
89+
90+
// ParseUnverified parses the token but doesn't validate the signature.
91+
--
92+
2.45.3
93+

SPECS/coredns/coredns.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Summary: Fast and flexible DNS server
44
Name: coredns
55
Version: 1.11.1
6-
Release: 17%{?dist}
6+
Release: 18%{?dist}
77
License: Apache License 2.0
88
Vendor: Microsoft Corporation
99
Distribution: Mariner
@@ -44,6 +44,7 @@ Patch8: coredns-example-net-test.patch
4444
Patch9: CVE-2024-53259.patch
4545
Patch10: CVE-2025-30204.patch
4646
Patch11: CVE-2025-29786.patch
47+
Patch12: CVE-2024-51744.patch
4748

4849
BuildRequires: msft-golang
4950

@@ -82,6 +83,9 @@ install -p -m 755 -t %{buildroot}%{_bindir} %{name}
8283
%{_bindir}/%{name}
8384

8485
%changelog
86+
* Fri Apr 11 2025 Archana Shettigar <v-shettigara@microsoft.com> - 1.11.1-18
87+
- Patch CVE-2024-51744
88+
8589
* Mon Mar 31 2025 Kshitiz Godara <kgodara@microsoft.com> - 1.11.1-17
8690
- Fix CVE-2025-29786 with an upstream patch
8791

0 commit comments

Comments
 (0)