Commit 30d10227c8 for bind

commit 30d10227c8c5f6e100fbaff5c6ac3967a1174143
Author: Nicki Křížek <nicki@isc.org>
Date:   Fri Nov 6 13:07:32 2026 +0000

    Check the CVE-2020-8617 TSIG request in pytest

    The check sent a hex blob through packet.pl: a request carrying a TSIG
    with an empty MAC and error BADSIG, which named used to accept as if
    it were a response, and then assert.  dnspython builds the same
    packet, byte for byte but the message ID, and the test now asserts the
    NOTAUTH/BADSIG reply rather than only that the server still answers.
    The old label called it BADTIME; the error it carries is BADSIG.

    Assisted-by: Claude:claude-opus-5-5

diff --git a/REUSE.toml b/REUSE.toml
index 7aa1ff9a25..5a85be7800 100644
--- a/REUSE.toml
+++ b/REUSE.toml
@@ -103,7 +103,6 @@ path = [
 	"bin/tests/system/statschannel/traffic.expect.6",
 	"bin/tests/system/tcp/1996-alloc_dnsbuf-crash-test.pkt",
 	"bin/tests/system/tsig/badlocation",
-	"bin/tests/system/tsig/badtime",
 	"bin/tests/system/unknown/large.out",
 	"bin/tests/system/xfer/ans5/badkeydata",
 	"bin/tests/system/xfer/ans5/badmessageid",
diff --git a/bin/tests/system/tsig/badtime b/bin/tests/system/tsig/badtime
deleted file mode 100644
index 7926404cfb..0000000000
--- a/bin/tests/system/tsig/badtime
+++ /dev/null
@@ -1,37 +0,0 @@
-# Transaction ID
-1122
-# Standard query
-0000
-# Questions: 1, Additional: 1
-0001 0000 0000 0001
-# QNAME: isc.org
-03 69 73 63 03 6F 72 67 00
-# Type: A (Host Address)
-0001
-# Class: IN
-0001
-# Specially crafted TSIG Resource Record
-# Name: "sha256"
-06 73 68 61 32 35 36 00
-# Type: TSIG (Transaction Signature)
-00fa
-# Class: ANY
-00ff
-# TTL: 0
-00000000
-# RdLen: 29
-001d
-# Algorithm Name: hmac-sha256
-0b 68 6D 61 63 2D 73 68 61 32 35 36 00
-# Time Signed: Jan 1, 1970 01:00:00.000000000 CET
-00 00 00 00 00 00
-# Fudge: 300
-012c
-# MAC Size: 0; MAC: empty
-0000
-# Original ID: 0
-0000
-# Error: BADSIG
-0010
-# Other Data Length: 0
-0000
diff --git a/bin/tests/system/tsig/tests.sh b/bin/tests/system/tsig/tests.sh
index fb1d4ca719..23a5a9efff 100644
--- a/bin/tests/system/tsig/tests.sh
+++ b/bin/tests/system/tsig/tests.sh
@@ -248,16 +248,6 @@ ret=0
 $KEYGEN -a hmac-sha256 -b 128 example.net >keygen.out3 2>&1 && ret=1
 grep "unknown algorithm" keygen.out3 >/dev/null || ret=1

-echo_i "check that a 'BADTIME' response with 'QR=0' is handled as a request"
-ret=0
-$PERL ../packet.pl -a 10.53.0.1 -p ${PORT} -t tcp <badtime >/dev/null || ret=1
-$DIG -p ${PORT} @10.53.0.1 version.bind txt ch >dig.out.verify || ret=1
-grep "status: NOERROR" dig.out.verify >/dev/null || ret=1
-if [ $ret -eq 1 ]; then
-  echo_i "failed"
-  status=1
-fi
-
 if "$PERL" -e 'use Net::DNS; use Net::DNS::Packet;' >/dev/null 2>&1; then
   echo_i "check that TSIG in the wrong place returns FORMERR"
   ret=0
diff --git a/bin/tests/system/tsig/tests_badtime.py b/bin/tests/system/tsig/tests_badtime.py
index ffcc5c6beb..08409c79f6 100644
--- a/bin/tests/system/tsig/tests_badtime.py
+++ b/bin/tests/system/tsig/tests_badtime.py
@@ -14,10 +14,17 @@ import time

 import dns.message
 import dns.query
+import dns.rcode
+import dns.rdataclass
+import dns.rdatatype
+import dns.rdtypes.ANY.TSIG
+import dns.rrset
 import dns.tsig
 import dns.tsigkeyring
 import pytest

+import isctest
+
 pytestmark = pytest.mark.extra_artifacts(
     [
         "ns1/named-fips.conf",
@@ -62,3 +69,26 @@ def test_tsig_badtime(named_port):
         dns.query.send_tcp(sock, wire, timeout())
         with pytest.raises(dns.tsig.PeerBadTime):
             dns.query.receive_tcp(sock, timeout(), keyring=keyring)
+
+
+def test_tsig_empty_mac_in_request(ns1):
+    # An empty MAC is acceptable in a response carrying BADSIG, never in a
+    # request (CVE-2020-8617).
+    msg = dns.message.make_query("isc.org.", "A", use_edns=False, flags=0)
+    msg.keyring = False  # the BADSIG reply is unsigned
+    tsig = dns.rdtypes.ANY.TSIG.TSIG(
+        dns.rdataclass.ANY,
+        dns.rdatatype.TSIG,
+        dns.tsig.HMAC_SHA256,
+        time_signed=0,
+        fudge=300,
+        mac=b"",
+        original_id=0,
+        error=dns.rcode.BADSIG,
+        other=b"",
+    )
+    msg.additional.append(dns.rrset.from_rdata("sha256.", 0, tsig))
+
+    res = isctest.query.tcp(msg, ns1.ip)
+    isctest.check.notauth(res)
+    assert res.tsig[0].error == dns.rcode.BADSIG