Skip to content

Commit 2ec1f91

Browse files
[AUTO-CHERRYPICK] Patch coredns for CVE-2025-30204 [HIGH] - branch main (#13220)
Co-authored-by: kgodara912 <kshigodara@outlook.com>
1 parent 4bb9a85 commit 2ec1f91

2 files changed

Lines changed: 80 additions & 3 deletions

File tree

SPECS/coredns/CVE-2025-30204.patch

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
From 52215bbe38134b0f05ba3bbc56288ef68813747d Mon Sep 17 00:00:00 2001
2+
From: Kshitiz Godara <kgodara@microsoft.com>
3+
Date: Sun, 30 Mar 2025 17:35:55 +0000
4+
Subject: [PATCH] Fix for CVE-2025-30204
5+
6+
Upstream source:
7+
https://github.com/golang-jwt/jwt/commit/0951d184286dece21f73c85673fd308786ffe9c3
8+
---
9+
vendor/github.com/golang-jwt/jwt/v4/parser.go | 37 +++++++++++++++++--
10+
1 file changed, 34 insertions(+), 3 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 c0a6f69..7b5ddfe 100644
14+
--- a/vendor/github.com/golang-jwt/jwt/v4/parser.go
15+
+++ b/vendor/github.com/golang-jwt/jwt/v4/parser.go
16+
@@ -7,6 +7,8 @@ import (
17+
"strings"
18+
)
19+
20+
+const tokenDelimiter = "."
21+
+
22+
type Parser struct {
23+
// If populated, only these methods will be considered valid.
24+
//
25+
@@ -123,9 +125,10 @@ func (p *Parser) ParseWithClaims(tokenString string, claims Claims, keyFunc Keyf
26+
// It's only ever useful in cases where you know the signature is valid (because it has
27+
// been checked previously in the stack) and you want to extract values from it.
28+
func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Token, parts []string, err error) {
29+
- parts = strings.Split(tokenString, ".")
30+
- if len(parts) != 3 {
31+
- return nil, parts, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed)
32+
+ var ok bool
33+
+ parts, ok = splitToken(tokenString)
34+
+ if !ok {
35+
+ return nil, nil, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed)
36+
}
37+
38+
token = &Token{Raw: tokenString}
39+
@@ -175,3 +178,31 @@ func (p *Parser) ParseUnverified(tokenString string, claims Claims) (token *Toke
40+
41+
return token, parts, nil
42+
}
43+
+
44+
+// splitToken splits a token string into three parts: header, claims, and signature. It will only
45+
+// return true if the token contains exactly two delimiters and three parts. In all other cases, it
46+
+// will return nil parts and false.
47+
+func splitToken(token string) ([]string, bool) {
48+
+ parts := make([]string, 3)
49+
+ header, remain, ok := strings.Cut(token, tokenDelimiter)
50+
+ if !ok {
51+
+ return nil, false
52+
+ }
53+
+ parts[0] = header
54+
+ claims, remain, ok := strings.Cut(remain, tokenDelimiter)
55+
+ if !ok {
56+
+ return nil, false
57+
+ }
58+
+ parts[1] = claims
59+
+ // One more cut to ensure the signature is the last part of the token and there are no more
60+
+ // delimiters. This avoids an issue where malicious input could contain additional delimiters
61+
+ // causing unecessary overhead parsing tokens.
62+
+ signature, _, unexpected := strings.Cut(remain, tokenDelimiter)
63+
+ if unexpected {
64+
+ return nil, false
65+
+ }
66+
+ parts[2] = signature
67+
+
68+
+ return parts, true
69+
+}
70+
+
71+
--
72+
2.45.3
73+

SPECS/coredns/coredns.spec

Lines changed: 7 additions & 3 deletions
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: 15%{?dist}
6+
Release: 16%{?dist}
77
License: Apache License 2.0
88
Vendor: Microsoft Corporation
99
Distribution: Mariner
@@ -42,6 +42,7 @@ Patch7: CVE-2025-22868.patch
4242
# https://github.com/coredns/coredns/commit/d8ecde1080e7cbbeb98257ba4e03a271f16b4cd9
4343
Patch8: coredns-example-net-test.patch
4444
Patch9: CVE-2024-53259.patch
45+
Patch10: CVE-2025-30204.patch
4546

4647
BuildRequires: msft-golang
4748

@@ -80,6 +81,9 @@ install -p -m 755 -t %{buildroot}%{_bindir} %{name}
8081
%{_bindir}/%{name}
8182

8283
%changelog
84+
* Mon Mar 31 2025 Kshitiz Godara <kgodara@microsoft.com> - 1.11.1-16
85+
- Fix CVE-2025-30204 with an upstream patch
86+
8387
* Wed Mar 19 2025 Mayank Singh <mayansingh@microsoft.com> - 1.11.1-15
8488
- Fix CVE-2024-53259 with an upstream patch
8589

@@ -110,7 +114,7 @@ install -p -m 755 -t %{buildroot}%{_bindir} %{name}
110114
* Wed Apr 17 2024 Bala <balakumaran.kannan@microsoft.com> - 1.11.1-6
111115
- Patched vendored quic-go package to address CVE-2024-22189
112116

113-
* Fri Feb 10 2024 Mykhailo Bykhovtsev <mbykhovtsev@microsoft.com> - 1.11.1-5
117+
* Sat Feb 10 2024 Mykhailo Bykhovtsev <mbykhovtsev@microsoft.com> - 1.11.1-5
114118
- patched vendored quic-go package to address CVE-2023-49295
115119

116120
* Thu Feb 08 2024 Muhammad Falak <mwani@microsoft.com> - 1.11.1-4
@@ -123,7 +127,7 @@ install -p -m 755 -t %{buildroot}%{_bindir} %{name}
123127
* Mon Jan 29 2024 Daniel McIlvaney <damcilva@microsoft.com> - 1.11.1-2
124128
- Address CVE-2023-44487 by patching vendored golang.org/x/net
125129

126-
* Tue Oct 18 2023 Nicolas Guibourge <nicolasg@microsoft.com> - 1.11.1-1
130+
* Wed Oct 18 2023 Nicolas Guibourge <nicolasg@microsoft.com> - 1.11.1-1
127131
- Upgrade to 1.11.1 to match version required by kubernetes
128132

129133
* Mon Oct 16 2023 CBL-Mariner Servicing Account <cblmargh@microsoft.com> - 1.9.3-10

0 commit comments

Comments
 (0)