diff -Nru samba-4.7.6+dfsg~ubuntu/debian/changelog samba-4.7.6+dfsg~ubuntu/debian/changelog --- samba-4.7.6+dfsg~ubuntu/debian/changelog 2018-11-08 18:09:36.000000000 +0000 +++ samba-4.7.6+dfsg~ubuntu/debian/changelog 2018-11-16 13:19:35.000000000 +0000 @@ -1,3 +1,24 @@ +samba (2:4.7.6+dfsg~ubuntu-0ubuntu2.5) bionic-security; urgency=medium + + * SECURITY UPDATE: Unprivileged adding of CNAME record causing loop in AD + Internal DNS server + - debian/patches/CVE-2018-14629.patch: add CNAME loop prevention using + counter in python/samba/tests/dns.py, selftest/knownfail.d/dns, + source4/dns_server/dns_query.c. + - CVE-2018-14629 + * SECURITY UPDATE: Double-free in Samba AD DC KDC with PKINIT + - debian/patches/CVE-2018-16841-1.patch: fix segfault on PKINIT with + mis-matching principal in source4/kdc/db-glue.c. + - debian/patches/CVE-2018-16841-2.patch: check for mismatching + principal in testprogs/blackbox/test_pkinit_heimdal.sh. + - CVE-2018-16841 + * SECURITY UPDATE: NULL pointer de-reference in Samba AD DC LDAP server + - debian/patches/CVE-2018-16851.patch: check ret before manipulating + blob in source4/ldap_server/ldap_server.c. + - CVE-2018-16851 + + -- Marc Deslauriers Fri, 16 Nov 2018 08:19:35 -0500 + samba (2:4.7.6+dfsg~ubuntu-0ubuntu2.4) bionic; urgency=medium * d/p/fix-rmdir.patch: fix the patch to not apply with offset, which diff -Nru samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-14629.patch samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-14629.patch --- samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-14629.patch 1970-01-01 00:00:00.000000000 +0000 +++ samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-14629.patch 2018-11-16 13:19:09.000000000 +0000 @@ -0,0 +1,92 @@ +From 805850d4b67eff263a8dab0999ab59e6243534f1 Mon Sep 17 00:00:00 2001 +From: Aaron Haslett +Date: Tue, 23 Oct 2018 17:25:51 +1300 +Subject: [PATCH 5/5] CVE-2018-14629 dns: CNAME loop prevention using counter + +Count number of answers generated by internal DNS query routine and stop at +20 to match Microsoft's loop prevention mechanism. + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=13600 + +Signed-off-by: Aaron Haslett +Reviewed-by: Andrew Bartlett +Reviewed-by: Garming Sam +--- + python/samba/tests/dns.py | 24 ++++++++++++++++++++++++ + selftest/knownfail.d/dns | 6 ++++++ + source4/dns_server/dns_query.c | 6 ++++++ + 3 files changed, 36 insertions(+) + +Index: samba-4.7.6+dfsg~ubuntu/python/samba/tests/dns.py +=================================================================== +--- samba-4.7.6+dfsg~ubuntu.orig/python/samba/tests/dns.py 2018-11-16 08:19:07.562100053 -0500 ++++ samba-4.7.6+dfsg~ubuntu/python/samba/tests/dns.py 2018-11-16 08:19:07.562100053 -0500 +@@ -798,6 +798,30 @@ class TestComplexQueries(DNSTest): + self.assertEquals(response.answers[1].name, name2) + self.assertEquals(response.answers[1].rdata, name0) + ++ def test_cname_loop(self): ++ cname1 = "cnamelooptestrec." + self.get_dns_domain() ++ cname2 = "cnamelooptestrec2." + self.get_dns_domain() ++ cname3 = "cnamelooptestrec3." + self.get_dns_domain() ++ self.make_dns_update(cname1, cname2, dnsp.DNS_TYPE_CNAME) ++ self.make_dns_update(cname2, cname3, dnsp.DNS_TYPE_CNAME) ++ self.make_dns_update(cname3, cname1, dnsp.DNS_TYPE_CNAME) ++ ++ p = self.make_name_packet(dns.DNS_OPCODE_QUERY) ++ questions = [] ++ ++ q = self.make_name_question(cname1, ++ dns.DNS_QTYPE_A, ++ dns.DNS_QCLASS_IN) ++ questions.append(q) ++ self.finish_name_packet(p, questions) ++ ++ (response, response_packet) =\ ++ self.dns_transaction_udp(p, host=self.server_ip) ++ ++ max_recursion_depth = 20 ++ self.assertEquals(len(response.answers), max_recursion_depth) ++ ++ + class TestInvalidQueries(DNSTest): + def setUp(self): + super(TestInvalidQueries, self).setUp() +Index: samba-4.7.6+dfsg~ubuntu/selftest/knownfail.d/dns +=================================================================== +--- samba-4.7.6+dfsg~ubuntu.orig/selftest/knownfail.d/dns 2018-11-16 08:19:07.562100053 -0500 ++++ samba-4.7.6+dfsg~ubuntu/selftest/knownfail.d/dns 2018-11-16 08:19:07.562100053 -0500 +@@ -45,3 +45,9 @@ samba.tests.dns.__main__.TestSimpleQueri + + # The SOA override should not pass against the RODC, it must not overstamp + samba.tests.dns.__main__.TestSimpleQueries.test_one_SOA_query\(rodc:local\) ++ ++# ++# rodc and vampire_dc require signed dns updates, so the test setup ++# fails, but the test does run on fl2003dc ++^samba.tests.dns.__main__.TestComplexQueries.test_cname_loop\(rodc:local\) ++^samba.tests.dns.__main__.TestComplexQueries.test_cname_loop\(vampire_dc:local\) +Index: samba-4.7.6+dfsg~ubuntu/source4/dns_server/dns_query.c +=================================================================== +--- samba-4.7.6+dfsg~ubuntu.orig/source4/dns_server/dns_query.c 2018-11-16 08:19:07.562100053 -0500 ++++ samba-4.7.6+dfsg~ubuntu/source4/dns_server/dns_query.c 2018-11-16 08:19:07.562100053 -0500 +@@ -40,6 +40,7 @@ + + #undef DBGC_CLASS + #define DBGC_CLASS DBGC_DNS ++#define MAX_Q_RECURSION_DEPTH 20 + + struct forwarder_string { + const char *forwarder; +@@ -470,6 +471,11 @@ static struct tevent_req *handle_dnsrpcr + state->answers = answers; + state->nsrecs = nsrecs; + ++ if (talloc_array_length(*answers) >= MAX_Q_RECURSION_DEPTH) { ++ tevent_req_done(req); ++ return tevent_req_post(req, ev); ++ } ++ + resolve_cname = ((rec->wType == DNS_TYPE_CNAME) && + ((question->question_type == DNS_QTYPE_A) || + (question->question_type == DNS_QTYPE_AAAA))); diff -Nru samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16841-1.patch samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16841-1.patch --- samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16841-1.patch 1970-01-01 00:00:00.000000000 +0000 +++ samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16841-1.patch 2018-11-16 13:19:20.000000000 +0000 @@ -0,0 +1,38 @@ +From b38900c353ca92365f144734c99d156cc39611d4 Mon Sep 17 00:00:00 2001 +From: Andrew Bartlett +Date: Tue, 23 Oct 2018 17:33:46 +1300 +Subject: [PATCH 3/5] CVE-2018-16841 heimdal: Fix segfault on PKINIT with + mis-matching principal + +In Heimdal KRB5_KDC_ERR_CLIENT_NAME_MISMATCH is an enum, so we tried to double-free +mem_ctx. + +This was introduced in 9a0263a7c316112caf0265237bfb2cfb3a3d370d for the +MIT KDC effort. + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=13628 + +Signed-off-by: Andrew Bartlett +Reviewed-by: Gary Lockyer +--- + source4/kdc/db-glue.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +Index: samba-4.7.6+dfsg~ubuntu/source4/kdc/db-glue.c +=================================================================== +--- samba-4.7.6+dfsg~ubuntu.orig/source4/kdc/db-glue.c 2018-11-16 08:19:17.754103654 -0500 ++++ samba-4.7.6+dfsg~ubuntu/source4/kdc/db-glue.c 2018-11-16 08:19:17.750103652 -0500 +@@ -2578,10 +2578,10 @@ samba_kdc_check_pkinit_ms_upn_match(krb5 + * comparison */ + if (!(orig_sid && target_sid && dom_sid_equal(orig_sid, target_sid))) { + talloc_free(mem_ctx); +-#ifdef KRB5_KDC_ERR_CLIENT_NAME_MISMATCH /* Heimdal */ +- return KRB5_KDC_ERR_CLIENT_NAME_MISMATCH; +-#elif defined(KRB5KDC_ERR_CLIENT_NAME_MISMATCH) /* MIT */ ++#if defined(KRB5KDC_ERR_CLIENT_NAME_MISMATCH) /* MIT */ + return KRB5KDC_ERR_CLIENT_NAME_MISMATCH; ++#else /* Heimdal (where this is an enum) */ ++ return KRB5_KDC_ERR_CLIENT_NAME_MISMATCH; + #endif + } + diff -Nru samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16841-2.patch samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16841-2.patch --- samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16841-2.patch 1970-01-01 00:00:00.000000000 +0000 +++ samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16841-2.patch 2018-11-16 13:19:23.000000000 +0000 @@ -0,0 +1,40 @@ +From 58733073f6eb78e8b157ee55493e92ffa361b73c Mon Sep 17 00:00:00 2001 +From: Andrew Bartlett +Date: Wed, 24 Oct 2018 15:41:28 +1300 +Subject: [PATCH 4/5] CVE-2018-16841 selftest: Check for mismatching principal + in certficate compared with principal in AS-REQ + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=13628 +Signed-off-by: Andrew Bartlett +Reviewed-by: Gary Lockyer +--- + testprogs/blackbox/test_pkinit_heimdal.sh | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/testprogs/blackbox/test_pkinit_heimdal.sh b/testprogs/blackbox/test_pkinit_heimdal.sh +index 0a13aa293e7..0912e0dbfe8 100755 +--- a/testprogs/blackbox/test_pkinit_heimdal.sh ++++ b/testprogs/blackbox/test_pkinit_heimdal.sh +@@ -75,10 +75,18 @@ testit "STEP1 kinit with pkinit (name specified) " $samba4kinit $enctype --reque + testit "STEP1 kinit renew ticket (name specified)" $samba4kinit --request-pac -R || failed=`expr $failed + 1` + test_smbclient "STEP1 Test login with kerberos ccache (name specified)" 'ls' "$unc" -k yes || failed=`expr $failed + 1` + ++testit_expect_failure "STEP1 kinit with pkinit (wrong name specified) " $samba4kinit $enctype --request-pac --renewable $PKUSER not$USERNAME@$REALM || failed=`expr $failed + 1` ++ ++testit_expect_failure "STEP1 kinit with pkinit (wrong name specified 2) " $samba4kinit $enctype --request-pac --renewable $PKUSER $SERVER@$REALM || failed=`expr $failed + 1` ++ + testit "STEP1 kinit with pkinit (enterprise name specified)" $samba4kinit $enctype --request-pac --renewable $PKUSER --enterprise $USERNAME@$REALM || failed=`expr $failed + 1` + testit "STEP1 kinit renew ticket (enterprise name specified)" $samba4kinit --request-pac -R || failed=`expr $failed + 1` + test_smbclient "STEP1 Test login with kerberos ccache (enterprise name specified)" 'ls' "$unc" -k yes || failed=`expr $failed + 1` + ++testit_expect_failure "STEP1 kinit with pkinit (wrong enterprise name specified) " $samba4kinit $enctype --request-pac --renewable $PKUSER --enterprise not$USERNAME@$REALM || failed=`expr $failed + 1` ++ ++testit_expect_failure "STEP1 kinit with pkinit (wrong enterprise name specified 2) " $samba4kinit $enctype --request-pac --renewable $PKUSER --enterprise $SERVER$@$REALM || failed=`expr $failed + 1` ++ + testit "STEP1 kinit with pkinit (enterprise name in cert)" $samba4kinit $enctype --request-pac --renewable $PKUSER --pk-enterprise || failed=`expr $failed + 1` + testit "STEP1 kinit renew ticket (enterprise name in cert)" $samba4kinit --request-pac -R || failed=`expr $failed + 1` + test_smbclient "STEP1 Test login with kerberos ccache (enterprise name in cert)" 'ls' "$unc" -k yes || failed=`expr $failed + 1` +-- +2.11.0 + + diff -Nru samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16851.patch samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16851.patch --- samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16851.patch 1970-01-01 00:00:00.000000000 +0000 +++ samba-4.7.6+dfsg~ubuntu/debian/patches/CVE-2018-16851.patch 2018-11-16 13:19:32.000000000 +0000 @@ -0,0 +1,41 @@ +From d8c836ef838a62b39c255bcb49443df171334d24 Mon Sep 17 00:00:00 2001 +From: Garming Sam +Date: Mon, 5 Nov 2018 16:18:18 +1300 +Subject: [PATCH 2/5] CVE-2018-16851 ldap_server: Check ret before manipulating + blob + +In the case of hitting the talloc ~256MB limit, this causes a crash in +the server. + +Note that you would actually need to load >256MB of data into the LDAP. +Although there is some generated/hidden data which would help you reach that +limit (descriptors and RMD blobs). + +BUG: https://bugzilla.samba.org/show_bug.cgi?id=13674 + +Signed-off-by: Garming Sam +Reviewed-by: Andrew Bartlett +--- + source4/ldap_server/ldap_server.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +Index: samba-4.7.6+dfsg~ubuntu/source4/ldap_server/ldap_server.c +=================================================================== +--- samba-4.7.6+dfsg~ubuntu.orig/source4/ldap_server/ldap_server.c 2018-11-16 08:19:30.186111421 -0500 ++++ samba-4.7.6+dfsg~ubuntu/source4/ldap_server/ldap_server.c 2018-11-16 08:19:30.186111421 -0500 +@@ -669,13 +669,13 @@ static void ldapsrv_call_writev_start(st + ret = data_blob_append(call, &blob, b.data, b.length); + data_blob_free(&b); + +- talloc_set_name_const(blob.data, "Outgoing, encoded LDAP packet"); +- + if (!ret) { + ldapsrv_terminate_connection(conn, "data_blob_append failed"); + return; + } + ++ talloc_set_name_const(blob.data, "Outgoing, encoded LDAP packet"); ++ + DLIST_REMOVE(call->replies, call->replies); + } + diff -Nru samba-4.7.6+dfsg~ubuntu/debian/patches/series samba-4.7.6+dfsg~ubuntu/debian/patches/series --- samba-4.7.6+dfsg~ubuntu/debian/patches/series 2018-11-08 18:09:36.000000000 +0000 +++ samba-4.7.6+dfsg~ubuntu/debian/patches/series 2018-11-16 13:19:28.000000000 +0000 @@ -33,3 +33,7 @@ CVE-2018-1139-5.patch CVE-2018-1139-6.patch fix-rmdir.patch +CVE-2018-14629.patch +CVE-2018-16841-1.patch +CVE-2018-16841-2.patch +CVE-2018-16851.patch