Skip to content

Commit eb5dffc

Browse files
authored
Fix CVE-2024-6104 in Prometheus by patching vendor gomodule (#9992)
1 parent 5512944 commit eb5dffc

2 files changed

Lines changed: 86 additions & 1 deletion

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
From 9aa3a166bf8eb6db0419cad5a1b7434de911f43d Mon Sep 17 00:00:00 2001
2+
From: Balakumaran Kannan <kumaran.4353@gmail.com>
3+
Date: Thu, 1 Aug 2024 12:34:56 +0000
4+
Subject: [PATCH] Patch CVE-2024-6104
5+
6+
---
7+
.../hashicorp/go-retryablehttp/client.go | 28 ++++++++++++++-----
8+
1 file changed, 21 insertions(+), 7 deletions(-)
9+
10+
diff --git a/vendor/github.com/hashicorp/go-retryablehttp/client.go b/vendor/github.com/hashicorp/go-retryablehttp/client.go
11+
index 57116e9..10a5f70 100644
12+
--- a/vendor/github.com/hashicorp/go-retryablehttp/client.go
13+
+++ b/vendor/github.com/hashicorp/go-retryablehttp/client.go
14+
@@ -577,9 +577,9 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
15+
if logger != nil {
16+
switch v := logger.(type) {
17+
case LeveledLogger:
18+
- v.Debug("performing request", "method", req.Method, "url", req.URL)
19+
+ v.Debug("performing request", "method", req.Method, "url", redactURL(req.URL))
20+
case Logger:
21+
- v.Printf("[DEBUG] %s %s", req.Method, req.URL)
22+
+ v.Printf("[DEBUG] %s %s", req.Method, redactURL(req.URL))
23+
}
24+
}
25+
26+
@@ -634,9 +634,9 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
27+
if err != nil {
28+
switch v := logger.(type) {
29+
case LeveledLogger:
30+
- v.Error("request failed", "error", err, "method", req.Method, "url", req.URL)
31+
+ v.Error("request failed", "error", err, "method", req.Method, "url", redactURL(req.URL))
32+
case Logger:
33+
- v.Printf("[ERR] %s %s request failed: %v", req.Method, req.URL, err)
34+
+ v.Printf("[ERR] %s %s request failed: %v", req.Method, redactURL(req.URL), err)
35+
}
36+
} else {
37+
// Call this here to maintain the behavior of logging all requests,
38+
@@ -672,7 +672,7 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
39+
40+
wait := c.Backoff(c.RetryWaitMin, c.RetryWaitMax, i, resp)
41+
if logger != nil {
42+
- desc := fmt.Sprintf("%s %s", req.Method, req.URL)
43+
+ desc := fmt.Sprintf("%s %s", req.Method, redactURL(req.URL))
44+
if resp != nil {
45+
desc = fmt.Sprintf("%s (status: %d)", desc, resp.StatusCode)
46+
}
47+
@@ -728,11 +728,11 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
48+
// communicate why
49+
if err == nil {
50+
return nil, fmt.Errorf("%s %s giving up after %d attempt(s)",
51+
- req.Method, req.URL, attempt)
52+
+ req.Method, redactURL(req.URL), attempt)
53+
}
54+
55+
return nil, fmt.Errorf("%s %s giving up after %d attempt(s): %w",
56+
- req.Method, req.URL, attempt, err)
57+
+ req.Method, redactURL(req.URL), attempt, err)
58+
}
59+
60+
// Try to read the response body so we can reuse this connection.
61+
@@ -813,3 +813,17 @@ func (c *Client) StandardClient() *http.Client {
62+
Transport: &RoundTripper{Client: c},
63+
}
64+
}
65+
+
66+
+
67+
+// Taken from url.URL#Redacted() which was introduced in go 1.15.
68+
+func redactURL(u *url.URL) string {
69+
+ if u == nil {
70+
+ return ""
71+
+ }
72+
+
73+
+ ru := *u
74+
+ if _, has := ru.User.Password(); has {
75+
+ ru.User = url.UserPassword(ru.User.Username(), "xxxxx")
76+
+ }
77+
+ return ru.String()
78+
+}
79+
--
80+
2.33.8
81+

SPECS/prometheus/prometheus.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Summary: Prometheus monitoring system and time series database
55
Name: prometheus
66
Version: 2.37.0
7-
Release: 13%{?dist}
7+
Release: 14%{?dist}
88
License: Apache-2.0
99
Vendor: Microsoft Corporation
1010
Distribution: Mariner
@@ -18,6 +18,7 @@ Source5: prometheus.logrotate
1818
Source6: promu-%{promu_version}.tar.gz
1919
# Debian patch for default settings
2020
Patch0: 02-Default_settings.patch
21+
Patch1: CVE-2024-6104.patch
2122
BuildRequires: golang
2223
BuildRequires: nodejs
2324
BuildRequires: systemd-rpm-macros
@@ -131,6 +132,9 @@ fi
131132
%doc README.md RELEASE.md documentation
132133

133134
%changelog
135+
* Thu Aug 01 2024 Bala <balakumaran.kannan@microsoft.com> - 2.37.0-14
136+
- Patch for CVE-2024-6104
137+
134138
* Thu Jun 06 2024 CBL-Mariner Servicing Account <cblmargh@microsoft.com> - 2.37.0-13
135139
- Bump release to rebuild with go 1.21.11
136140

0 commit comments

Comments
 (0)