]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
CVE-2020-14303 Ensure an empty packet will not DoS the NBT server
authorAndrew Bartlett <abartlet@samba.org>
Wed, 24 Jun 2020 23:59:54 +0000 (11:59 +1200)
committerKarolin Seeger <kseeger@samba.org>
Thu, 25 Jun 2020 11:04:45 +0000 (13:04 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
(backported from master commit)
[abartlet@samba.org: Remove f"" format string not supported in
 Python 3.4]

python/samba/tests/dns_packet.py
selftest/knownfail.d/empty-nbt [new file with mode: 0644]

index a9996664e57e8aa900c7c7db65424dec7b0fcc1f..68e4d154cade8401145dcfe86fc8f18c57f36f42 100644 (file)
@@ -155,6 +155,19 @@ class TestDnsPacketBase(TestCase):
         rcode = self.decode_reply(data)['rcode']
         return expected_rcode == rcode
 
+    def _test_empty_packet(self):
+
+        packet = b""
+        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+        s.sendto(packet, self.server)
+        s.close()
+
+        # It is reasonable not to reply to an empty packet
+        # but it is not reasonable to render the server
+        # unresponsive.
+        ok = self._known_good_query()
+        self.assertTrue(ok, "the server is unresponsive")
+
 
 class TestDnsPackets(TestDnsPacketBase):
     server = (SERVER, 53)
@@ -173,6 +186,9 @@ class TestDnsPackets(TestDnsPacketBase):
         label = b'x.' * 31 + b'x'
         self._test_many_repeated_components(label, 127)
 
+    def test_empty_packet(self):
+        self._test_empty_packet()
+
 
 class TestNbtPackets(TestDnsPacketBase):
     server = (SERVER, 137)
@@ -208,3 +224,6 @@ class TestNbtPackets(TestDnsPacketBase):
     def test_127_half_dotty_components(self):
         label = b'x.' * 31 + b'x'
         self._test_many_repeated_components(label, 127)
+
+    def test_empty_packet(self):
+        self._test_empty_packet()
diff --git a/selftest/knownfail.d/empty-nbt b/selftest/knownfail.d/empty-nbt
new file mode 100644 (file)
index 0000000..e4bccca
--- /dev/null
@@ -0,0 +1 @@
+^samba.tests.dns_packet.samba.tests.dns_packet.TestNbtPackets.test_empty_packet
\ No newline at end of file