Skip to content

Commit dcfae22

Browse files
committed
(PA-6699) Bump puppet-agent's bundled openssl 3.0 to address CVE-2024-5535
1 parent 8402339 commit dcfae22

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

configs/components/openssl-3.0.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@
121121
'no-whirlpool'
122122
]
123123

124+
# Remove this in 3.0.15 or later
125+
pkg.apply_patch 'resources/patches/openssl/CVE-2024-5535.patch'
126+
124127
if settings[:use_legacy_openssl_algos]
125128
pkg.apply_patch 'resources/patches/openssl/openssl-3-activate-legacy-algos.patch'
126129
else
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
From cf6f91f6121f4db167405db2f0de410a456f260c Fri May 31 11:14:33 2024 +0100
2+
author Matt Caswell <[email protected]> Fri May 31 11:14:33 2024 +0100
3+
committer Matt Caswell <[email protected]> Thu Jun 27 10:39:47 2024 +0100
4+
5+
Fix SSL_select_next_proto
6+
7+
Ensure that the provided client list is non-NULL and starts with a valid
8+
entry. When called from the ALPN callback the client list should already
9+
have been validated by OpenSSL so this should not cause a problem. When
10+
called from the NPN callback the client list is locally configured and
11+
will not have already been validated. Therefore SSL_select_next_proto
12+
should not assume that it is correctly formatted.
13+
14+
We implement stricter checking of the client protocol list. We also do the
15+
same for the server list while we are about it.
16+
17+
CVE-2024-5535
18+
19+
Reviewed-by: Neil Horman <[email protected]>
20+
Reviewed-by: Tomas Mraz <[email protected]>
21+
(Merged from https://github.com/openssl/openssl/pull/24718)
22+
23+
(cherry picked from commit 4ada436a1946cbb24db5ab4ca082b69c1bc10f37)
24+
25+
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
26+
index cb4e006ea7..e628140dfa 100644
27+
--- a/ssl/ssl_lib.c
28+
+++ b/ssl/ssl_lib.c
29+
@@ -2952,37 +2952,54 @@ int SSL_select_next_proto(unsigned char **out, unsigned char *outlen,
30+
unsigned int server_len,
31+
const unsigned char *client, unsigned int client_len)
32+
{
33+
- unsigned int i, j;
34+
- const unsigned char *result;
35+
- int status = OPENSSL_NPN_UNSUPPORTED;
36+
+ PACKET cpkt, csubpkt, spkt, ssubpkt;
37+
+
38+
+ if (!PACKET_buf_init(&cpkt, client, client_len)
39+
+ || !PACKET_get_length_prefixed_1(&cpkt, &csubpkt)
40+
+ || PACKET_remaining(&csubpkt) == 0) {
41+
+ *out = NULL;
42+
+ *outlen = 0;
43+
+ return OPENSSL_NPN_NO_OVERLAP;
44+
+ }
45+
+
46+
+ /*
47+
+ * Set the default opportunistic protocol. Will be overwritten if we find
48+
+ * a match.
49+
+ */
50+
+ *out = (unsigned char *)PACKET_data(&csubpkt);
51+
+ *outlen = (unsigned char)PACKET_remaining(&csubpkt);
52+
53+
/*
54+
* For each protocol in server preference order, see if we support it.
55+
*/
56+
- for (i = 0; i < server_len;) {
57+
- for (j = 0; j < client_len;) {
58+
- if (server[i] == client[j] &&
59+
- memcmp(&server[i + 1], &client[j + 1], server[i]) == 0) {
60+
- /* We found a match */
61+
- result = &server[i];
62+
- status = OPENSSL_NPN_NEGOTIATED;
63+
- goto found;
64+
+ if (PACKET_buf_init(&spkt, server, server_len)) {
65+
+ while (PACKET_get_length_prefixed_1(&spkt, &ssubpkt)) {
66+
+ if (PACKET_remaining(&ssubpkt) == 0)
67+
+ continue; /* Invalid - ignore it */
68+
+ if (PACKET_buf_init(&cpkt, client, client_len)) {
69+
+ while (PACKET_get_length_prefixed_1(&cpkt, &csubpkt)) {
70+
+ if (PACKET_equal(&csubpkt, PACKET_data(&ssubpkt),
71+
+ PACKET_remaining(&ssubpkt))) {
72+
+ /* We found a match */
73+
+ *out = (unsigned char *)PACKET_data(&ssubpkt);
74+
+ *outlen = (unsigned char)PACKET_remaining(&ssubpkt);
75+
+ return OPENSSL_NPN_NEGOTIATED;
76+
+ }
77+
+ }
78+
+ /* Ignore spurious trailing bytes in the client list */
79+
+ } else {
80+
+ /* This should never happen */
81+
+ return OPENSSL_NPN_NO_OVERLAP;
82+
}
83+
- j += client[j];
84+
- j++;
85+
}
86+
- i += server[i];
87+
- i++;
88+
+ /* Ignore spurious trailing bytes in the server list */
89+
}
90+
91+
- /* There's no overlap between our protocols and the server's list. */
92+
- result = client;
93+
- status = OPENSSL_NPN_NO_OVERLAP;
94+
-
95+
- found:
96+
- *out = (unsigned char *)result + 1;
97+
- *outlen = result[0];
98+
- return status;
99+
+ /*
100+
+ * There's no overlap between our protocols and the server's list. We use
101+
+ * the default opportunistic protocol selected earlier
102+
+ */
103+
+ return OPENSSL_NPN_NO_OVERLAP;
104+
}
105+
106+
#ifndef OPENSSL_NO_NEXTPROTONEG

0 commit comments

Comments
 (0)