Skip to content

Commit 4a467cb

Browse files
[AUTO-CHERRYPICK] dhcp: fix CVE-2022-38177, CVE-2022-38178, CVE-2022-2795 for bind - branch main (#9094)
Co-authored-by: elainezhao96 <102555676+elainezhao96@users.noreply.github.com>
1 parent a714e12 commit 4a467cb

4 files changed

Lines changed: 145 additions & 2 deletions

File tree

SPECS/dhcp/CVE-2022-2795.patch

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
From 36c878a0124973f29b7ca49e6bb18310f9b2601f Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= <michal@isc.org>
3+
Date: Thu, 8 Sep 2022 11:11:30 +0200
4+
Subject: [PATCH 1/3] Bound the amount of work performed for delegations
5+
6+
Limit the amount of database lookups that can be triggered in
7+
fctx_getaddresses() (i.e. when determining the name server addresses to
8+
query next) by setting a hard limit on the number of NS RRs processed
9+
for any delegation encountered. Without any limit in place, named can
10+
be forced to perform large amounts of database lookups per each query
11+
received, which severely impacts resolver performance.
12+
13+
The limit used (20) is an arbitrary value that is considered to be big
14+
enough for any sane DNS delegation.
15+
16+
(cherry picked from commit 3a44097fd6c6c260765b628cd1d2c9cb7efb0b2a)
17+
18+
Upstream-Status: Backport
19+
CVE: CVE-2022-2795
20+
Reference to upstream patch:
21+
https://gitlab.isc.org/isc-projects/bind9/-/commit/bf2ea6d8525bfd96a84dad221ba9e004adb710a8
22+
23+
Signed-off-by: Mathieu Dubois-Briand <mbriand@witekio.com>
24+
---
25+
bind_ln/lib/dns/resolver.c | 12 ++++++++++++
26+
1 file changed, 12 insertions(+)
27+
28+
diff --git a/bind_ln/lib/dns/resolver.c b/bind_ln/lib/dns/resolver.c
29+
index 8ae9a993bbd7..ac9a9ef5d009 100644
30+
--- a/bind_ln/lib/dns/resolver.c
31+
+++ b/bind_ln/lib/dns/resolver.c
32+
@@ -180,6 +180,12 @@
33+
*/
34+
#define NS_FAIL_LIMIT 4
35+
#define NS_RR_LIMIT 5
36+
+/*
37+
+ * IP address lookups are performed for at most NS_PROCESSING_LIMIT NS RRs in
38+
+ * any NS RRset encountered, to avoid excessive resource use while processing
39+
+ * large delegations.
40+
+ */
41+
+#define NS_PROCESSING_LIMIT 20
42+
43+
/* Number of hash buckets for zone counters */
44+
#ifndef RES_DOMAIN_BUCKETS
45+
@@ -3318,6 +3324,7 @@ fctx_getaddresses(fetchctx_t *fctx, bool badcache) {
46+
bool need_alternate = false;
47+
bool all_spilled = true;
48+
unsigned int no_addresses = 0;
49+
+ unsigned int ns_processed = 0;
50+
51+
FCTXTRACE5("getaddresses", "fctx->depth=", fctx->depth);
52+
53+
@@ -3504,6 +3511,11 @@ fctx_getaddresses(fetchctx_t *fctx, bool badcache) {
54+
55+
dns_rdata_reset(&rdata);
56+
dns_rdata_freestruct(&ns);
57+
+
58+
+ if (++ns_processed >= NS_PROCESSING_LIMIT) {
59+
+ result = ISC_R_NOMORE;
60+
+ break;
61+
+ }
62+
}
63+
if (result != ISC_R_NOMORE) {
64+
return (result);
65+
--
66+
2.34.1
67+

SPECS/dhcp/CVE-2022-38177.patch

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From ef3d1a84ff807eea27b4fef601a15932c5ffbfbf Mon Sep 17 00:00:00 2001
2+
From: Mark Andrews <marka@isc.org>
3+
Date: Thu, 11 Aug 2022 15:15:34 +1000
4+
Subject: [PATCH 2/3] Free eckey on siglen mismatch
5+
6+
Upstream-Status: Backport
7+
CVE: CVE-2022-38177
8+
Reference to upstream patch:
9+
https://gitlab.isc.org/isc-projects/bind9/-/commit/5b2282afff760b1ed3471f6666bdfe8e1d34e590
10+
11+
Signed-off-by: Mathieu Dubois-Briand <mbriand@witekio.com>
12+
---
13+
bind_ln/lib/dns/opensslecdsa_link.c | 2 +-
14+
1 file changed, 1 insertion(+), 1 deletion(-)
15+
16+
diff --git a/bind_ln/lib/dns/opensslecdsa_link.c b/bind_ln/lib/dns/opensslecdsa_link.c
17+
index 83b5b51cd78c..7576e04ac635 100644
18+
--- a/bind_ln/lib/dns/opensslecdsa_link.c
19+
+++ b/bind_ln/lib/dns/opensslecdsa_link.c
20+
@@ -224,7 +224,7 @@ opensslecdsa_verify(dst_context_t *dctx, const isc_region_t *sig) {
21+
siglen = DNS_SIG_ECDSA384SIZE;
22+
23+
if (sig->length != siglen)
24+
- return (DST_R_VERIFYFAILURE);
25+
+ DST_RET(DST_R_VERIFYFAILURE);
26+
27+
if (!EVP_DigestFinal_ex(evp_md_ctx, digest, &dgstlen))
28+
DST_RET (dst__openssl_toresult3(dctx->category,
29+
--
30+
2.34.1
31+

SPECS/dhcp/CVE-2022-38178.patch

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 65f5b2f0162d5d2ab25f463aa14a8bae71ace3d9 Mon Sep 17 00:00:00 2001
2+
From: Mark Andrews <marka@isc.org>
3+
Date: Thu, 11 Aug 2022 15:28:13 +1000
4+
Subject: [PATCH 3/3] Free ctx on invalid siglen
5+
6+
(cherry picked from commit 6ddb480a84836641a0711768a94122972c166825)
7+
8+
Upstream-Status: Backport
9+
CVE: CVE-2022-38178
10+
Reference to upstream patch:
11+
https://gitlab.isc.org/isc-projects/bind9/-/commit/1af23378ebb11da2eb0f412e4563d6
12+
13+
Signed-off-by: Mathieu Dubois-Briand <mbriand@witekio.com>
14+
---
15+
bind_ln/lib/dns/openssleddsa_link.c | 2 +-
16+
1 file changed, 1 insertion(+), 1 deletion(-)
17+
18+
diff --git a/bind_ln/lib/dns/openssleddsa_link.c b/bind_ln/lib/dns/openssleddsa_link.c
19+
index 8b115ec283f0..b4fcd607c131 100644
20+
--- a/bind_ln/lib/dns/openssleddsa_link.c
21+
+++ b/bind_ln/lib/dns/openssleddsa_link.c
22+
@@ -325,7 +325,7 @@ openssleddsa_verify(dst_context_t *dctx, const isc_region_t *sig) {
23+
siglen = DNS_SIG_ED448SIZE;
24+
25+
if (sig->length != siglen)
26+
- return (DST_R_VERIFYFAILURE);
27+
+ DST_RET(ISC_R_NOTIMPLEMENTED);
28+
29+
isc_buffer_usedregion(buf, &tbsreg);
30+
31+
--
32+
2.34.1
33+

SPECS/dhcp/dhcp.spec

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
Summary: Dynamic host configuration protocol
22
Name: dhcp
33
Version: 4.4.3
4-
Release: 1%{?dist}
4+
Release: 2%{?dist}
55
License: MPLv2.0
66
Url: https://www.isc.org/dhcp/
77
Source0: ftp://ftp.isc.org/isc/dhcp/%{version}/%{name}-%{version}.tar.gz
8+
Patch0: CVE-2022-38177.patch
9+
Patch1: CVE-2022-38178.patch
10+
Patch2: CVE-2022-2795.patch
811
Group: System Environment/Base
912
Vendor: Microsoft Corporation
1013
Distribution: Mariner
@@ -38,7 +41,13 @@ The ISC DHCP Client, dhclient, provides a means for configuring one or more netw
3841

3942

4043
%prep
41-
%autosetup -p1
44+
%setup -q -n dhcp-%{version}
45+
46+
# Extracting bundled 'bind' to allow some of the patches to modify it.
47+
tar -C bind -xf bind/bind.tar.gz
48+
ln -s bind/bind-9* bind_ln
49+
50+
%autopatch -p1
4251

4352
%build
4453
CFLAGS="$CFLAGS \
@@ -169,6 +178,9 @@ mkdir -p %{buildroot}%{_localstatedir}/lib/dhclient/
169178
%{_mandir}/man8/dhclient.8.gz
170179

171180
%changelog
181+
* Tue Apr 30 2024 Elaine Zhao <elainezhao@microsoft.com> - 4.4.3-2
182+
- Fix CVE-2022-38177, CVE-2022-38178, CVE-2022-2795 for bundled bind
183+
172184
* Tue Apr 23 2024 CBL-Mariner Servicing Account <cblmargh@microsoft.com> - 4.4.3-1
173185
- Auto-upgrade to 4.4.3 - Fix for CVE-2022-2928 and CVE-2022-2929
174186

0 commit comments

Comments
 (0)