Skip to content

Commit e95e418

Browse files
[MEDIUM] Patch helm for CVE-2025-32386 & CVE-2025-22872 (#13454)
Co-authored-by: Kanishk Bansal <103916909+Kanishk-Bansal@users.noreply.github.com>
1 parent 840228a commit e95e418

4 files changed

Lines changed: 139 additions & 5 deletions

File tree

SPECS/helm/CVE-2025-22872.patch

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
From c87c77a12e5554d376945bd488e56d4fc5b9e5ac Mon Sep 17 00:00:00 2001
2+
From: archana25-ms <v-shettigara@microsoft.com>
3+
Date: Tue, 22 Apr 2025 06:32:35 +0000
4+
Subject: [PATCH] Address CVE-2025-22872
5+
Upstream Patch Reference: https://github.com/golang/net/commit/e1fcd82abba34df74614020343be8eb1fe85f0d9
6+
7+
---
8+
vendor/golang.org/x/net/html/token.go | 18 ++++++++++++++++--
9+
1 file changed, 16 insertions(+), 2 deletions(-)
10+
11+
diff --git a/vendor/golang.org/x/net/html/token.go b/vendor/golang.org/x/net/html/token.go
12+
index 3c57880..6598c1f 100644
13+
--- a/vendor/golang.org/x/net/html/token.go
14+
+++ b/vendor/golang.org/x/net/html/token.go
15+
@@ -839,8 +839,22 @@ func (z *Tokenizer) readStartTag() TokenType {
16+
if raw {
17+
z.rawTag = strings.ToLower(string(z.buf[z.data.start:z.data.end]))
18+
}
19+
- // Look for a self-closing token like "<br/>".
20+
- if z.err == nil && z.buf[z.raw.end-2] == '/' {
21+
+ // Look for a self-closing token (e.g. <br/>).
22+
+ //
23+
+ // Originally, we did this by just checking that the last character of the
24+
+ // tag (ignoring the closing bracket) was a solidus (/) character, but this
25+
+ // is not always accurate.
26+
+ //
27+
+ // We need to be careful that we don't misinterpret a non-self-closing tag
28+
+ // as self-closing, as can happen if the tag contains unquoted attribute
29+
+ // values (i.e. <p a=/>).
30+
+ //
31+
+ // To avoid this, we check that the last non-bracket character of the tag
32+
+ // (z.raw.end-2) isn't the same character as the last non-quote character of
33+
+ // the last attribute of the tag (z.pendingAttr[1].end-1), if the tag has
34+
+ // attributes.
35+
+ nAttrs := len(z.attr)
36+
+ if z.err == nil && z.buf[z.raw.end-2] == '/' && (nAttrs == 0 || z.raw.end-2 != z.attr[nAttrs-1][1].end-1) {
37+
return SelfClosingTagToken
38+
}
39+
return StartTagToken
40+
--
41+
2.45.3
42+

SPECS/helm/CVE-2025-32386.patch

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
From e58d689dcb58dc14838b8d643b2d6b39d54420be Mon Sep 17 00:00:00 2001
2+
From: archana25-ms <v-shettigara@microsoft.com>
3+
Date: Thu, 17 Apr 2025 10:18:29 +0000
4+
Subject: [PATCH] Address CVE-2025-32386 & CVE-2025-32387
5+
Upstream Patch Reference: https://github.com/helm/helm/commit/d8ca55fc669645c10c0681d49723f4bb8c0b1ce7
6+
---
7+
pkg/chart/loader/archive.go | 32 +++++++++++++++++++++++++++++++-
8+
pkg/chart/loader/directory.go | 4 ++++
9+
2 files changed, 35 insertions(+), 1 deletion(-)
10+
11+
diff --git a/pkg/chart/loader/archive.go b/pkg/chart/loader/archive.go
12+
index 196e5f8..4cb994c 100644
13+
--- a/pkg/chart/loader/archive.go
14+
+++ b/pkg/chart/loader/archive.go
15+
@@ -33,6 +33,15 @@ import (
16+
"helm.sh/helm/v3/pkg/chart"
17+
)
18+
19+
+// MaxDecompressedChartSize is the maximum size of a chart archive that will be
20+
+// decompressed. This is the decompressed size of all the files.
21+
+// The default value is 100 MiB.
22+
+var MaxDecompressedChartSize int64 = 100 * 1024 * 1024 // Default 100 MiB
23+
+
24+
+// MaxDecompressedFileSize is the size of the largest file that Helm will attempt to load.
25+
+// The size of the file is the decompressed version of it when it is stored in an archive.
26+
+var MaxDecompressedFileSize int64 = 5 * 1024 * 1024 // Default 5 MiB
27+
+
28+
var drivePathPattern = regexp.MustCompile(`^[a-zA-Z]:/`)
29+
30+
// FileLoader loads a chart from a file
31+
@@ -119,6 +128,7 @@ func LoadArchiveFiles(in io.Reader) ([]*BufferedFile, error) {
32+
33+
files := []*BufferedFile{}
34+
tr := tar.NewReader(unzipped)
35+
+ remainingSize := MaxDecompressedChartSize
36+
for {
37+
b := bytes.NewBuffer(nil)
38+
hd, err := tr.Next()
39+
@@ -178,10 +188,30 @@ func LoadArchiveFiles(in io.Reader) ([]*BufferedFile, error) {
40+
return nil, errors.New("chart yaml not in base directory")
41+
}
42+
43+
- if _, err := io.Copy(b, tr); err != nil {
44+
+ if hd.Size > remainingSize {
45+
+ return nil, fmt.Errorf("decompressed chart is larger than the maximum size %d", MaxDecompressedChartSize)
46+
+ }
47+
+
48+
+ if hd.Size > MaxDecompressedFileSize {
49+
+ return nil, fmt.Errorf("decompressed chart file %q is larger than the maximum file size %d", hd.Name, MaxDecompressedFileSize)
50+
+ }
51+
+
52+
+ limitedReader := io.LimitReader(tr, remainingSize)
53+
+
54+
+ bytesWritten, err := io.Copy(b, limitedReader)
55+
+ if err != nil {
56+
return nil, err
57+
}
58+
59+
+ remainingSize -= bytesWritten
60+
+ // When the bytesWritten are less than the file size it means the limit reader ended
61+
+ // copying early. Here we report that error. This is important if the last file extracted
62+
+ // is the one that goes over the limit. It assumes the Size stored in the tar header
63+
+ // is correct, something many applications do.
64+
+ if bytesWritten < hd.Size || remainingSize <= 0 {
65+
+ return nil, fmt.Errorf("decompressed chart is larger than the maximum size %d", MaxDecompressedChartSize)
66+
+ }
67+
+
68+
data := bytes.TrimPrefix(b.Bytes(), utf8bom)
69+
70+
files = append(files, &BufferedFile{Name: n, Data: data})
71+
diff --git a/pkg/chart/loader/directory.go b/pkg/chart/loader/directory.go
72+
index 9bcbee6..fd8e02e 100644
73+
--- a/pkg/chart/loader/directory.go
74+
+++ b/pkg/chart/loader/directory.go
75+
@@ -101,6 +101,10 @@ func LoadDir(dir string) (*chart.Chart, error) {
76+
return fmt.Errorf("cannot load irregular file %s as it has file mode type bits set", name)
77+
}
78+
79+
+ if fi.Size() > MaxDecompressedFileSize {
80+
+ return fmt.Errorf("chart file %q is larger than the maximum file size %d", fi.Name(), MaxDecompressedFileSize)
81+
+ }
82+
+
83+
data, err := os.ReadFile(name)
84+
if err != nil {
85+
return errors.Wrapf(err, "error reading %s", n)
86+
--
87+
2.45.3
88+

SPECS/helm/helm.spec

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
Name: helm
44
Version: 3.14.2
5-
Release: 5%{?dist}
5+
Release: 6%{?dist}
66
Summary: The Kubernetes Package Manager
77
Group: Applications/Networking
88
License: Apache 2.0
99
Vendor: Microsoft Corporation
1010
Distribution: Mariner
1111
Url: https://github.com/helm/helm
12-
#Source0: https://github.com/%{name}/%{name}/archive/v%{version}.tar.gz
13-
Source0: %{name}-%{version}.tar.gz
12+
Source0: https://github.com/helm/helm/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
1413
# Below is a manually created tarball, no download link.
1514
# We're using pre-populated Go modules from this tarball, since network is disabled during build time.
1615
# How to re-build this file:
@@ -27,13 +26,15 @@ Source0: %{name}-%{version}.tar.gz
2726
Source1: %{name}-%{version}-vendor.tar.gz
2827
Patch0: CVE-2023-45288.patch
2928
Patch1: CVE-2024-45338.patch
29+
Patch2: CVE-2025-32386.patch
30+
Patch3: CVE-2025-22872.patch
3031
BuildRequires: golang
3132

3233
%description
3334
Helm is a tool that streamlines installing and managing Kubernetes applications. Think of it like apt/yum/homebrew for Kubernetes.
3435

3536
%prep
36-
%autosetup -p1 -a 1
37+
%autosetup -p1 -a1
3738

3839
%build
3940
export VERSION=%{version}
@@ -56,6 +57,9 @@ install -m 755 ./helm %{buildroot}%{_bindir}
5657
go test -v ./cmd/helm
5758

5859
%changelog
60+
* Thu Apr 17 2025 Archana Shettigar <v-shettigara@microsoft.com> - 3.14.2-6
61+
- Patch CVE-2025-32386 & CVE-2025-22872
62+
5963
* Fri Jan 03 2025 Sumedh Sharma <sumsharma@microsoft.com> - 3.14.2-5
6064
- Add patch for CVE-2024-45338
6165

cgmanifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5231,7 +5231,7 @@
52315231
"other": {
52325232
"name": "helm",
52335233
"version": "3.14.2",
5234-
"downloadUrl": "https://github.com/helm/helm/archive/v3.14.2.tar.gz"
5234+
"downloadUrl": "https://github.com/helm/helm/archive/refs/tags/v3.14.2.tar.gz"
52355235
}
52365236
}
52375237
},

0 commit comments

Comments
 (0)