Skip to content

Commit aca522d

Browse files
mfrwjslobodzian
andauthored
cert-manager: address CVE-2024-45337 (#11817)
Signed-off-by: Muhammad Falak R Wani <[email protected]> Co-authored-by: jslobodzian <[email protected]>
1 parent bd01bb7 commit aca522d

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
From 784057d777784f1737dbf5d660f32bf2577add4c Mon Sep 17 00:00:00 2001
2+
From: Roland Shoemaker <[email protected]>
3+
Date: Tue, 3 Dec 2024 09:03:03 -0800
4+
Subject: [PATCH] ssh: make the public key cache a 1-entry FIFO cache
5+
6+
Users of the the ssh package seem to extremely commonly misuse the
7+
PublicKeyCallback API, assuming that the key passed in the last call
8+
before a connection is established is the key used for authentication.
9+
Some users then make authorization decisions based on this key. This
10+
property is not documented, and may not be correct, due to the caching
11+
behavior of the package, resulting in users making incorrect
12+
authorization decisions about the connection.
13+
14+
This change makes the cache a one entry FIFO cache, making the assumed
15+
property, that the last call to PublicKeyCallback represents the key
16+
actually used for authentication, actually hold.
17+
18+
Thanks to Damien Tournoud, Patrick Dawkins, Vince Parker, and
19+
Jules Duvivier from the Platform.sh / Upsun engineering team
20+
for reporting this issue.
21+
22+
Fixes golang/go#70779
23+
Fixes CVE-2024-45337
24+
25+
Change-Id: Ife7c7b4045d8b6bcd7e3a417bdfae370c709797f
26+
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/635315
27+
Reviewed-by: Roland Shoemaker <[email protected]>
28+
Auto-Submit: Gopher Robot <[email protected]>
29+
Reviewed-by: Damien Neil <[email protected]>
30+
Reviewed-by: Nicola Murino <[email protected]>
31+
LUCI-TryBot-Result: Go LUCI <[email protected]>
32+
Signed-off-by: Muhammad Falak R Wani <[email protected]>
33+
---
34+
.../vendor/golang.org/x/crypto/ssh/server.go | 15 +++++++++++----
35+
1 file changed, 11 insertions(+), 4 deletions(-)
36+
37+
diff --git a/cmd/controller/vendor/golang.org/x/crypto/ssh/server.go b/cmd/controller/vendor/golang.org/x/crypto/ssh/server.go
38+
index 3ca9e89..a8b673c 100644
39+
--- a/cmd/controller/vendor/golang.org/x/crypto/ssh/server.go
40+
+++ b/cmd/controller/vendor/golang.org/x/crypto/ssh/server.go
41+
@@ -149,7 +149,7 @@ func (s *ServerConfig) AddHostKey(key Signer) {
42+
}
43+
44+
// cachedPubKey contains the results of querying whether a public key is
45+
-// acceptable for a user.
46+
+// acceptable for a user. This is a FIFO cache.
47+
type cachedPubKey struct {
48+
user string
49+
pubKeyData []byte
50+
@@ -157,7 +157,13 @@ type cachedPubKey struct {
51+
perms *Permissions
52+
}
53+
54+
-const maxCachedPubKeys = 16
55+
+// maxCachedPubKeys is the number of cache entries we store.
56+
+//
57+
+// Due to consistent misuse of the PublicKeyCallback API, we have reduced this
58+
+// to 1, such that the only key in the cache is the most recently seen one. This
59+
+// forces the behavior that the last call to PublicKeyCallback will always be
60+
+// with the key that is used for authentication.
61+
+const maxCachedPubKeys = 1
62+
63+
// pubKeyCache caches tests for public keys. Since SSH clients
64+
// will query whether a public key is acceptable before attempting to
65+
@@ -179,9 +185,10 @@ func (c *pubKeyCache) get(user string, pubKeyData []byte) (cachedPubKey, bool) {
66+
67+
// add adds the given tuple to the cache.
68+
func (c *pubKeyCache) add(candidate cachedPubKey) {
69+
- if len(c.keys) < maxCachedPubKeys {
70+
- c.keys = append(c.keys, candidate)
71+
+ if len(c.keys) >= maxCachedPubKeys {
72+
+ c.keys = c.keys[1:]
73+
}
74+
+ c.keys = append(c.keys, candidate)
75+
}
76+
77+
// ServerConn is an authenticated SSH connection, as seen from the
78+
--
79+
2.34.1
80+

SPECS/cert-manager/cert-manager.spec

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: Automatically provision and manage TLS certificates in Kubernetes
22
Name: cert-manager
33
Version: 1.12.13
4-
Release: 1%{?dist}
4+
Release: 2%{?dist}
55
License: ASL 2.0
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
@@ -13,6 +13,7 @@ Source0: https://github.com/jetstack/%{name}/archive/refs/tags/v%{version
1313
# 1. wget https://github.com/jetstack/%%{name}/archive/refs/tags/v%%{version}.tar.gz -O %%{name}-%%{version}.tar.gz
1414
# 2. <repo-root>/SPECS/cert-manager/generate_source_tarball.sh --srcTarball %%{name}-%%{version}.tar.gz --pkgVersion %%{version}
1515
Source1: %{name}-%{version}-vendor.tar.gz
16+
Patch0: CVE-2024-45337.patch
1617
BuildRequires: golang
1718
Requires: %{name}-acmesolver
1819
Requires: %{name}-cainjector
@@ -57,7 +58,7 @@ Summary: cert-manager's webhook binary
5758
Webhook component providing API validation, mutation and conversion functionality for cert-manager.
5859

5960
%prep
60-
%setup -q -a 1
61+
%autosetup -a 1 -p1
6162

6263
%build
6364

@@ -103,6 +104,9 @@ install -D -m0755 bin/webhook %{buildroot}%{_bindir}/
103104
%{_bindir}/webhook
104105

105106
%changelog
107+
* Wed Jan 08 2025 Muhammad Falak <[email protected]> - 1.12.13-2
108+
- Patch CVE-2024-45337
109+
106110
* Mon Sep 16 2024 Jiri Appl <[email protected]> - 1.12.13-1
107111
- Upgrade to 1.12.13 which carries helm 3.14.2 to fix CVE-2024-26147 and CVE-2024-25620
108112

0 commit comments

Comments
 (0)