Blame SOURCES/bind-9.11-CVE-2021-25220-test.patch

744bbe
From 800ef75553881527e2406f22887e976bb1ba3bfe Mon Sep 17 00:00:00 2001
744bbe
From: Mark Andrews <marka@isc.org>
744bbe
Date: Tue, 18 Jan 2022 00:19:47 +1100
744bbe
Subject: [PATCH] Add tests for forwarder cache poisoning scenarios
744bbe
744bbe
- Check that an NS in an authority section returned from a forwarder
744bbe
  which is above the name in a configured "forward first" or "forward
744bbe
  only" zone (i.e., net/NS in a response from a forwarder configured for
744bbe
  local.net) is not cached.
744bbe
- Test that a DNAME for a parent domain will not be cached when sent
744bbe
  in a response from a forwarder configured to answer for a child.
744bbe
- Check that glue is rejected if its name falls below that of zone
744bbe
  configured locally.
744bbe
- Check that an extra out-of-bailiwick data in the answer section is
744bbe
  not cached (this was already working correctly, but was not explicitly
744bbe
  tested before).
744bbe
744bbe
- v9_11 backport: Revert primary/secondary to master/slave,
744bbe
  backport rndc helper, backport ns8 config.
744bbe
744bbe
(cherry picked from commit bf3fffff67e1de78e9387a93674d471bf4291604)
744bbe
(cherry picked from commit 29f08170f05c2c96fb67f3b561b46aa0bae356f7)
744bbe
---
744bbe
 bin/tests/system/forward/ans11/ans.py         | 136 ++++++++++++++++++
744bbe
 bin/tests/system/forward/clean.sh             |   2 +
744bbe
 bin/tests/system/forward/ns1/diditwork.net.db |  20 +++
744bbe
 bin/tests/system/forward/ns1/named.conf.in    |  20 +++
744bbe
 bin/tests/system/forward/ns1/net.example.lll  |  13 ++
744bbe
 bin/tests/system/forward/ns1/spoofed.net.db   |  20 +++
744bbe
 bin/tests/system/forward/ns1/sub.local.net.db |  20 +++
744bbe
 bin/tests/system/forward/ns10/fakenet.zone    |  15 ++
744bbe
 bin/tests/system/forward/ns10/fakenet2.zone   |  13 ++
744bbe
 .../system/forward/ns10/fakesublocalnet.zone  |  13 ++
744bbe
 .../system/forward/ns10/fakesublocaltld.zone  |  13 ++
744bbe
 bin/tests/system/forward/ns10/named.conf.in   |  51 +++++++
744bbe
 bin/tests/system/forward/ns10/net.example.lll |  13 ++
744bbe
 bin/tests/system/forward/ns10/spoofednet.zone |  14 ++
744bbe
 bin/tests/system/forward/ns4/named.conf.in    |   5 +
744bbe
 bin/tests/system/forward/ns4/sibling.tld.db   |  20 +++
744bbe
 bin/tests/system/forward/ns8/named.conf.in    |  33 +++++
744bbe
 bin/tests/system/forward/ns8/root.db          |  11 ++
744bbe
 bin/tests/system/forward/ns8/sub.local.tld.db |  13 ++
744bbe
 bin/tests/system/forward/ns9/local.net.db     |  14 ++
744bbe
 bin/tests/system/forward/ns9/local.tld.db     |  13 ++
744bbe
 bin/tests/system/forward/ns9/named1.conf.in   |  65 +++++++++
744bbe
 bin/tests/system/forward/ns9/named2.conf.in   |  68 +++++++++
744bbe
 bin/tests/system/forward/ns9/named3.conf.in   |  48 +++++++
744bbe
 bin/tests/system/forward/ns9/named4.conf.in   |  45 ++++++
744bbe
 bin/tests/system/forward/ns9/root.db          |  11 ++
744bbe
 bin/tests/system/forward/prereq.sh            |  14 ++
744bbe
 bin/tests/system/forward/setup.sh             |   3 +
744bbe
 bin/tests/system/forward/tests.sh             | 126 ++++++++++++++++
744bbe
 bin/tests/system/ifconfig.sh                  |   8 +-
744bbe
 30 files changed, 856 insertions(+), 4 deletions(-)
744bbe
 create mode 100644 bin/tests/system/forward/ans11/ans.py
744bbe
 create mode 100644 bin/tests/system/forward/ns1/diditwork.net.db
744bbe
 create mode 100644 bin/tests/system/forward/ns1/net.example.lll
744bbe
 create mode 100644 bin/tests/system/forward/ns1/spoofed.net.db
744bbe
 create mode 100644 bin/tests/system/forward/ns1/sub.local.net.db
744bbe
 create mode 100644 bin/tests/system/forward/ns10/fakenet.zone
744bbe
 create mode 100644 bin/tests/system/forward/ns10/fakenet2.zone
744bbe
 create mode 100644 bin/tests/system/forward/ns10/fakesublocalnet.zone
744bbe
 create mode 100644 bin/tests/system/forward/ns10/fakesublocaltld.zone
744bbe
 create mode 100644 bin/tests/system/forward/ns10/named.conf.in
744bbe
 create mode 100644 bin/tests/system/forward/ns10/net.example.lll
744bbe
 create mode 100644 bin/tests/system/forward/ns10/spoofednet.zone
744bbe
 create mode 100644 bin/tests/system/forward/ns4/sibling.tld.db
744bbe
 create mode 100644 bin/tests/system/forward/ns8/named.conf.in
744bbe
 create mode 100644 bin/tests/system/forward/ns8/root.db
744bbe
 create mode 100644 bin/tests/system/forward/ns8/sub.local.tld.db
744bbe
 create mode 100644 bin/tests/system/forward/ns9/local.net.db
744bbe
 create mode 100644 bin/tests/system/forward/ns9/local.tld.db
744bbe
 create mode 100644 bin/tests/system/forward/ns9/named1.conf.in
744bbe
 create mode 100644 bin/tests/system/forward/ns9/named2.conf.in
744bbe
 create mode 100644 bin/tests/system/forward/ns9/named3.conf.in
744bbe
 create mode 100644 bin/tests/system/forward/ns9/named4.conf.in
744bbe
 create mode 100644 bin/tests/system/forward/ns9/root.db
744bbe
744bbe
diff --git a/bin/tests/system/forward/ans11/ans.py b/bin/tests/system/forward/ans11/ans.py
744bbe
new file mode 100644
744bbe
index 0000000000..2956cf6eff
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ans11/ans.py
744bbe
@@ -0,0 +1,136 @@
744bbe
+############################################################################
744bbe
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+#
744bbe
+# This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+# License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+#
744bbe
+# See the COPYRIGHT file distributed with this work for additional
744bbe
+# information regarding copyright ownership.
744bbe
+############################################################################
744bbe
+
744bbe
+from __future__ import print_function
744bbe
+import os
744bbe
+import sys
744bbe
+import signal
744bbe
+import socket
744bbe
+import select
744bbe
+from datetime import datetime, timedelta
744bbe
+import time
744bbe
+import functools
744bbe
+
744bbe
+import dns, dns.message, dns.query, dns.flags
744bbe
+from dns.rdatatype import *
744bbe
+from dns.rdataclass import *
744bbe
+from dns.rcode import *
744bbe
+from dns.name import *
744bbe
+
744bbe
+# Log query to file
744bbe
+def logquery(type, qname):
744bbe
+    with open("qlog", "a") as f:
744bbe
+        f.write("%s %s\n", type, qname)
744bbe
+
744bbe
+############################################################################
744bbe
+# Respond to a DNS query.
744bbe
+############################################################################
744bbe
+def create_response(msg):
744bbe
+    m = dns.message.from_wire(msg)
744bbe
+    qname = m.question[0].name.to_text()
744bbe
+    rrtype = m.question[0].rdtype
744bbe
+    typename = dns.rdatatype.to_text(rrtype)
744bbe
+
744bbe
+    with open("query.log", "a") as f:
744bbe
+        f.write("%s %s\n" % (typename, qname))
744bbe
+        print("%s %s" % (typename, qname), end=" ")
744bbe
+
744bbe
+    r = dns.message.make_response(m)
744bbe
+    r.set_rcode(NOERROR)
744bbe
+    if rrtype == A:
744bbe
+        tld=qname.split('.')[-2] + '.'
744bbe
+        ns="local." + tld
744bbe
+        r.answer.append(dns.rrset.from_text(qname, 300, IN, A, "10.53.0.11"))
744bbe
+        r.answer.append(dns.rrset.from_text(tld, 300, IN, NS, "local." + tld))
744bbe
+        r.additional.append(dns.rrset.from_text(ns, 300, IN, A, "10.53.0.11"))
744bbe
+    elif rrtype == NS:
744bbe
+        r.answer.append(dns.rrset.from_text(qname, 300, IN, NS, "."))
744bbe
+    elif rrtype == SOA:
744bbe
+        r.answer.append(dns.rrset.from_text(qname, 300, IN, SOA, ". . 0 0 0 0 0"))
744bbe
+    else:
744bbe
+        r.authority.append(dns.rrset.from_text(qname, 300, IN, SOA, ". . 0 0 0 0 0"))
744bbe
+    r.flags |= dns.flags.AA
744bbe
+    return r
744bbe
+
744bbe
+def sigterm(signum, frame):
744bbe
+    print ("Shutting down now...")
744bbe
+    os.remove('ans.pid')
744bbe
+    running = False
744bbe
+    sys.exit(0)
744bbe
+
744bbe
+############################################################################
744bbe
+# Main
744bbe
+#
744bbe
+# Set up responder and control channel, open the pid file, and start
744bbe
+# the main loop, listening for queries on the query channel or commands
744bbe
+# on the control channel and acting on them.
744bbe
+############################################################################
744bbe
+ip4 = "10.53.0.11"
744bbe
+ip6 = "fd92:7065:b8e:ffff::11"
744bbe
+
744bbe
+try: port=int(os.environ['PORT'])
744bbe
+except: port=5300
744bbe
+
744bbe
+query4_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
744bbe
+query4_socket.bind((ip4, port))
744bbe
+havev6 = True
744bbe
+try:
744bbe
+    query6_socket = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
744bbe
+    try:
744bbe
+        query6_socket.bind((ip6, port))
744bbe
+    except:
744bbe
+        query6_socket.close()
744bbe
+        havev6 = False
744bbe
+except:
744bbe
+    havev6 = False
744bbe
+signal.signal(signal.SIGTERM, sigterm)
744bbe
+
744bbe
+f = open('ans.pid', 'w')
744bbe
+pid = os.getpid()
744bbe
+print (pid, file=f)
744bbe
+f.close()
744bbe
+
744bbe
+running = True
744bbe
+
744bbe
+print ("Listening on %s port %d" % (ip4, port))
744bbe
+if havev6:
744bbe
+    print ("Listening on %s port %d" % (ip6, port))
744bbe
+print ("Ctrl-c to quit")
744bbe
+
744bbe
+if havev6:
744bbe
+    input = [query4_socket, query6_socket]
744bbe
+else:
744bbe
+    input = [query4_socket]
744bbe
+
744bbe
+while running:
744bbe
+    try:
744bbe
+        inputready, outputready, exceptready = select.select(input, [], [])
744bbe
+    except select.error as e:
744bbe
+        break
744bbe
+    except socket.error as e:
744bbe
+        break
744bbe
+    except KeyboardInterrupt:
744bbe
+        break
744bbe
+
744bbe
+    for s in inputready:
744bbe
+        if s == query4_socket or s == query6_socket:
744bbe
+            print ("Query received on %s" %
744bbe
+                    (ip4 if s == query4_socket else ip6), end=" ")
744bbe
+            # Handle incoming queries
744bbe
+            msg = s.recvfrom(65535)
744bbe
+            rsp = create_response(msg[0])
744bbe
+            if rsp:
744bbe
+                print(dns.rcode.to_text(rsp.rcode()))
744bbe
+                s.sendto(rsp.to_wire(), msg[1])
744bbe
+            else:
744bbe
+                print("NO RESPONSE")
744bbe
+    if not running:
744bbe
+        break
744bbe
diff --git a/bin/tests/system/forward/clean.sh b/bin/tests/system/forward/clean.sh
744bbe
index 26e4e76db6..26a550db49 100644
744bbe
--- a/bin/tests/system/forward/clean.sh
744bbe
+++ b/bin/tests/system/forward/clean.sh
744bbe
@@ -10,8 +10,10 @@
744bbe
 #
744bbe
 # Clean up after forward tests.
744bbe
 #
744bbe
+rm -f ./ans11/query.log
744bbe
 rm -f ./dig.out.*
744bbe
 rm -f ./*/named.conf
744bbe
 rm -f ./*/named.memstats
744bbe
 rm -f ./*/named.run ./*/named.run.prev
744bbe
+rm -f ./*/named_dump.db
744bbe
 rm -f ./ns*/named.lock
744bbe
diff --git a/bin/tests/system/forward/ns1/diditwork.net.db b/bin/tests/system/forward/ns1/diditwork.net.db
744bbe
new file mode 100644
744bbe
index 0000000000..be9a7f72bc
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns1/diditwork.net.db
744bbe
@@ -0,0 +1,20 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+$TTL 300	; 5 minutes
744bbe
+@			IN SOA	ns root (
744bbe
+				2000082401 ; serial
744bbe
+				1800       ; refresh (30 minutes)
744bbe
+				1800       ; retry (30 minutes)
744bbe
+				1814400    ; expire (3 weeks)
744bbe
+				3600       ; minimum (1 hour)
744bbe
+				)
744bbe
+			NS	ns
744bbe
+			TXT	"recursed"
744bbe
+ns			A	10.53.0.1
744bbe
diff --git a/bin/tests/system/forward/ns1/named.conf.in b/bin/tests/system/forward/ns1/named.conf.in
744bbe
index 9904f37ef5..1c31d84608 100644
744bbe
--- a/bin/tests/system/forward/ns1/named.conf.in
744bbe
+++ b/bin/tests/system/forward/ns1/named.conf.in
744bbe
@@ -54,3 +54,23 @@ zone "example5." {
744bbe
 zone "example6" {
744bbe
 	type forward;
744bbe
 };
744bbe
+
744bbe
+zone "diditwork.net" {
744bbe
+	type master;
744bbe
+	file "diditwork.net.db";
744bbe
+};
744bbe
+
744bbe
+zone "spoofed.net" {
744bbe
+	type master;
744bbe
+	file "spoofed.net.db";
744bbe
+};
744bbe
+
744bbe
+zone "sub.local.net" {
744bbe
+	type master;
744bbe
+	file "sub.local.net.db";
744bbe
+};
744bbe
+
744bbe
+zone "net.example.lll" {
744bbe
+	type master;
744bbe
+	file "net.example.lll";
744bbe
+};
744bbe
diff --git a/bin/tests/system/forward/ns1/net.example.lll b/bin/tests/system/forward/ns1/net.example.lll
744bbe
new file mode 100644
744bbe
index 0000000000..d179853fa5
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns1/net.example.lll
744bbe
@@ -0,0 +1,13 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+$TTL 86400
744bbe
+net.example.lll.		SOA	. . 0 0 0 0 0
744bbe
+net.example.lll.		NS	attackSecureDomain.net.
744bbe
+didItWork.net.example.lll.	TXT	"if you can see this record the attack worked"
744bbe
diff --git a/bin/tests/system/forward/ns1/spoofed.net.db b/bin/tests/system/forward/ns1/spoofed.net.db
744bbe
new file mode 100644
744bbe
index 0000000000..d498d5fa0d
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns1/spoofed.net.db
744bbe
@@ -0,0 +1,20 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+$TTL 300	; 5 minutes
744bbe
+@			IN SOA	ns root (
744bbe
+				2000082401 ; serial
744bbe
+				1800       ; refresh (30 minutes)
744bbe
+				1800       ; retry (30 minutes)
744bbe
+				1814400    ; expire (3 weeks)
744bbe
+				3600       ; minimum (1 hour)
744bbe
+				)
744bbe
+			NS	ns
744bbe
+ns			A	10.53.0.1
744bbe
+sub			TXT	"recursed"
744bbe
diff --git a/bin/tests/system/forward/ns1/sub.local.net.db b/bin/tests/system/forward/ns1/sub.local.net.db
744bbe
new file mode 100644
744bbe
index 0000000000..be9a7f72bc
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns1/sub.local.net.db
744bbe
@@ -0,0 +1,20 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+$TTL 300	; 5 minutes
744bbe
+@			IN SOA	ns root (
744bbe
+				2000082401 ; serial
744bbe
+				1800       ; refresh (30 minutes)
744bbe
+				1800       ; retry (30 minutes)
744bbe
+				1814400    ; expire (3 weeks)
744bbe
+				3600       ; minimum (1 hour)
744bbe
+				)
744bbe
+			NS	ns
744bbe
+			TXT	"recursed"
744bbe
+ns			A	10.53.0.1
744bbe
diff --git a/bin/tests/system/forward/ns10/fakenet.zone b/bin/tests/system/forward/ns10/fakenet.zone
744bbe
new file mode 100644
744bbe
index 0000000000..14e5c777cb
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns10/fakenet.zone
744bbe
@@ -0,0 +1,15 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+$TTL 86400
744bbe
+net.			SOA	. . 0 0 0 0 0
744bbe
+net.			NS	attackSecureDomain.net.
744bbe
+attackSecureDomain.net.	A	10.53.0.10
744bbe
+didItWork.net.		TXT	"if you can see this record the attack worked"
744bbe
+ns.spoofed.net.		A	10.53.0.10
744bbe
diff --git a/bin/tests/system/forward/ns10/fakenet2.zone b/bin/tests/system/forward/ns10/fakenet2.zone
744bbe
new file mode 100644
744bbe
index 0000000000..7ca28a934e
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns10/fakenet2.zone
744bbe
@@ -0,0 +1,13 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+$TTL 86400
744bbe
+net2.			SOA	. . 0 0 0 0 0
744bbe
+net2.			NS	attackSecureDomain.net.
744bbe
+net2.			DNAME	net.example.lll.
744bbe
diff --git a/bin/tests/system/forward/ns10/fakesublocalnet.zone b/bin/tests/system/forward/ns10/fakesublocalnet.zone
744bbe
new file mode 100644
744bbe
index 0000000000..6caa071891
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns10/fakesublocalnet.zone
744bbe
@@ -0,0 +1,13 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+$TTL 86400
744bbe
+sub.local.net.		SOA	. . 0 0 0 0 0
744bbe
+sub.local.net.		NS	ns.spoofed.net.
744bbe
+sub.local.net.		TXT	"if you see this attacker overrode local delegation"
744bbe
diff --git a/bin/tests/system/forward/ns10/fakesublocaltld.zone b/bin/tests/system/forward/ns10/fakesublocaltld.zone
744bbe
new file mode 100644
744bbe
index 0000000000..6a431de47f
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns10/fakesublocaltld.zone
744bbe
@@ -0,0 +1,13 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+sub.local.tld.		3600	IN	SOA	. . 0 0 0 0 0
744bbe
+sub.local.tld.		3600	IN	NS	ns.sub.local.tld.
744bbe
+sub.local.tld.		3600	IN	TXT	bad
744bbe
+ns.sub.local.tld.	3600	IN	A	10.53.0.8
744bbe
diff --git a/bin/tests/system/forward/ns10/named.conf.in b/bin/tests/system/forward/ns10/named.conf.in
744bbe
new file mode 100644
744bbe
index 0000000000..025c108418
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns10/named.conf.in
744bbe
@@ -0,0 +1,51 @@
744bbe
+/*
744bbe
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+ *
744bbe
+ * This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+ *
744bbe
+ * See the COPYRIGHT file distributed with this work for additional
744bbe
+ * information regarding copyright ownership.
744bbe
+ */
744bbe
+
744bbe
+options {
744bbe
+	query-source address 10.53.0.10;
744bbe
+	notify-source 10.53.0.10;
744bbe
+	transfer-source 10.53.0.10;
744bbe
+	port @PORT@;
744bbe
+	pid-file "named.pid";
744bbe
+	listen-on { 10.53.0.10; };
744bbe
+	listen-on-v6 { none; };
744bbe
+	minimal-responses no;
744bbe
+};
744bbe
+
744bbe
+zone "net." {
744bbe
+	type master;
744bbe
+	file "fakenet.zone";
744bbe
+};
744bbe
+
744bbe
+zone "spoofed.net." {
744bbe
+	type master;
744bbe
+	file "spoofednet.zone";
744bbe
+};
744bbe
+
744bbe
+zone "sub.local.net." {
744bbe
+	type master;
744bbe
+	file "fakesublocalnet.zone";
744bbe
+};
744bbe
+
744bbe
+zone "net2" {
744bbe
+	type master;
744bbe
+	file "fakenet2.zone";
744bbe
+};
744bbe
+
744bbe
+zone "net.example.lll" {
744bbe
+	type master;
744bbe
+	file "net.example.lll";
744bbe
+};
744bbe
+
744bbe
+zone "sub.local.tld." {
744bbe
+	type master;
744bbe
+	file "fakesublocaltld.zone";
744bbe
+};
744bbe
diff --git a/bin/tests/system/forward/ns10/net.example.lll b/bin/tests/system/forward/ns10/net.example.lll
744bbe
new file mode 100644
744bbe
index 0000000000..d179853fa5
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns10/net.example.lll
744bbe
@@ -0,0 +1,13 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+$TTL 86400
744bbe
+net.example.lll.		SOA	. . 0 0 0 0 0
744bbe
+net.example.lll.		NS	attackSecureDomain.net.
744bbe
+didItWork.net.example.lll.	TXT	"if you can see this record the attack worked"
744bbe
diff --git a/bin/tests/system/forward/ns10/spoofednet.zone b/bin/tests/system/forward/ns10/spoofednet.zone
744bbe
new file mode 100644
744bbe
index 0000000000..13921a08cd
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns10/spoofednet.zone
744bbe
@@ -0,0 +1,14 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+$TTL 86400
744bbe
+spoofed.net.		SOA	. . 0 0 0 0 0
744bbe
+spoofed.net.		NS	ns.spoofed.net.
744bbe
+ns.spoofed.net.		A	10.53.0.10
744bbe
+spoofed.net.		TXT	"this record is clearly spoofed"
744bbe
diff --git a/bin/tests/system/forward/ns4/named.conf.in b/bin/tests/system/forward/ns4/named.conf.in
744bbe
index d42a9eb797..6db65e71bc 100644
744bbe
--- a/bin/tests/system/forward/ns4/named.conf.in
744bbe
+++ b/bin/tests/system/forward/ns4/named.conf.in
744bbe
@@ -60,3 +60,8 @@ zone "malicious." {
744bbe
 	type master;
744bbe
 	file "malicious.db";
744bbe
 };
744bbe
+
744bbe
+zone "sibling.tld" {
744bbe
+	type master;
744bbe
+	file "sibling.tld.db";
744bbe
+};
744bbe
diff --git a/bin/tests/system/forward/ns4/sibling.tld.db b/bin/tests/system/forward/ns4/sibling.tld.db
744bbe
new file mode 100644
744bbe
index 0000000000..58037d093b
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns4/sibling.tld.db
744bbe
@@ -0,0 +1,20 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+$TTL    86400
744bbe
+@       IN      SOA     malicious. admin.malicious. (
744bbe
+                              1         ; Serial
744bbe
+                         604800         ; Refresh
744bbe
+                          86400         ; Retry
744bbe
+                        2419200         ; Expire
744bbe
+                          86400 )       ; Negative Cache TTL
744bbe
+
744bbe
+@           IN    NS      ns
744bbe
+
744bbe
+ns          IN    A       10.53.0.4
744bbe
diff --git a/bin/tests/system/forward/ns8/named.conf.in b/bin/tests/system/forward/ns8/named.conf.in
744bbe
new file mode 100644
744bbe
index 0000000000..9260f69ded
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns8/named.conf.in
744bbe
@@ -0,0 +1,33 @@
744bbe
+/*
744bbe
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+ *
744bbe
+ * This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+ *
744bbe
+ * See the COPYRIGHT file distributed with this work for additional
744bbe
+ * information regarding copyright ownership.
744bbe
+ */
744bbe
+
744bbe
+options {
744bbe
+	query-source address 10.53.0.8;
744bbe
+	notify-source 10.53.0.8;
744bbe
+	transfer-source 10.53.0.8;
744bbe
+	port @PORT@;
744bbe
+	pid-file "named.pid";
744bbe
+	listen-on { 10.53.0.8; };
744bbe
+	listen-on-v6 { none; };
744bbe
+	forwarders { 10.53.0.2; };	// returns referrals
744bbe
+	forward first;
744bbe
+	dnssec-validation yes;
744bbe
+};
744bbe
+
744bbe
+zone "." {
744bbe
+	type hint;
744bbe
+	file "root.db";
744bbe
+};
744bbe
+
744bbe
+zone "sub.local.tld" {
744bbe
+	type master;
744bbe
+	file "sub.local.tld.db";
744bbe
+};
744bbe
diff --git a/bin/tests/system/forward/ns8/root.db b/bin/tests/system/forward/ns8/root.db
744bbe
new file mode 100644
744bbe
index 0000000000..4f30322270
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns8/root.db
744bbe
@@ -0,0 +1,11 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+.			NS	a.root-servers.nil.
744bbe
+a.root-servers.nil.	A	10.53.0.1
744bbe
diff --git a/bin/tests/system/forward/ns8/sub.local.tld.db b/bin/tests/system/forward/ns8/sub.local.tld.db
744bbe
new file mode 100644
744bbe
index 0000000000..eb20683ae9
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns8/sub.local.tld.db
744bbe
@@ -0,0 +1,13 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+sub.local.tld.		3600	IN	SOA	. . 0 0 0 0 0
744bbe
+sub.local.tld.		3600	IN	NS	ns.sub.local.tld.
744bbe
+sub.local.tld.		3600	IN	TXT	good
744bbe
+ns.sub.local.tld.	3600	IN	A	10.53.0.8
744bbe
diff --git a/bin/tests/system/forward/ns9/local.net.db b/bin/tests/system/forward/ns9/local.net.db
744bbe
new file mode 100644
744bbe
index 0000000000..2c971e1e93
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns9/local.net.db
744bbe
@@ -0,0 +1,14 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+local.net.		3600	IN	SOA	. . 0 0 0 0 0
744bbe
+local.net.		3600	IN	NS	localhost.
744bbe
+ns.local.net.		3600	IN	A	10.53.0.9
744bbe
+txt.local.net.		3600	IN	TXT	"something in the local auth zone"
744bbe
+sub.local.net.		3600	IN	NS	ns.spoofed.net.  ; attacker will try to override this
744bbe
diff --git a/bin/tests/system/forward/ns9/local.tld.db b/bin/tests/system/forward/ns9/local.tld.db
744bbe
new file mode 100644
744bbe
index 0000000000..59403915fb
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns9/local.tld.db
744bbe
@@ -0,0 +1,13 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+local.tld.		3600	IN	SOA	. . 0 0 0 0 0
744bbe
+local.tld.		3600	IN	NS	localhost.
744bbe
+sub.local.tld.		3600	IN	NS	ns.sub.local.tld.
744bbe
+ns.sub.local.tld.	3600	IN	A	10.53.0.8
744bbe
diff --git a/bin/tests/system/forward/ns9/named1.conf.in b/bin/tests/system/forward/ns9/named1.conf.in
744bbe
new file mode 100644
744bbe
index 0000000000..943e037d09
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns9/named1.conf.in
744bbe
@@ -0,0 +1,65 @@
744bbe
+/*
744bbe
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+ *
744bbe
+ * This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+ *
744bbe
+ * See the COPYRIGHT file distributed with this work for additional
744bbe
+ * information regarding copyright ownership.
744bbe
+ */
744bbe
+
744bbe
+options {
744bbe
+	query-source address 10.53.0.9;
744bbe
+	notify-source 10.53.0.9;
744bbe
+	transfer-source 10.53.0.9;
744bbe
+	port @PORT@;
744bbe
+	pid-file "named.pid";
744bbe
+	listen-on { 10.53.0.9; };
744bbe
+	listen-on-v6 { none; };
744bbe
+	dnssec-validation no;
744bbe
+	edns-udp-size 1232;
744bbe
+};
744bbe
+
744bbe
+key rndc_key {
744bbe
+	secret "1234abcd8765";
744bbe
+	algorithm hmac-sha256;
744bbe
+};
744bbe
+
744bbe
+controls {
744bbe
+	inet 10.53.0.9 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
744bbe
+};
744bbe
+
744bbe
+server 10.53.0.10 {
744bbe
+	edns no;
744bbe
+};
744bbe
+
744bbe
+server 10.53.0.11 {
744bbe
+	edns no;
744bbe
+};
744bbe
+
744bbe
+zone "." {
744bbe
+	type hint;
744bbe
+	file "root.db";
744bbe
+};
744bbe
+
744bbe
+zone "attacksecuredomain.net." {
744bbe
+	type forward;
744bbe
+	forwarders { 10.53.0.10; };
744bbe
+};
744bbe
+
744bbe
+zone "attacksecuredomain.net2." {
744bbe
+	type forward;
744bbe
+	forwarders { 10.53.0.10; };
744bbe
+};
744bbe
+
744bbe
+zone "attacksecuredomain.net3." {
744bbe
+	type forward;
744bbe
+	forwarders { 10.53.0.11; };
744bbe
+};
744bbe
+
744bbe
+zone "local.net." {
744bbe
+	type master;
744bbe
+	file "local.net.db";
744bbe
+	forwarders {};
744bbe
+};
744bbe
diff --git a/bin/tests/system/forward/ns9/named2.conf.in b/bin/tests/system/forward/ns9/named2.conf.in
744bbe
new file mode 100644
744bbe
index 0000000000..5a17d1998a
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns9/named2.conf.in
744bbe
@@ -0,0 +1,68 @@
744bbe
+/*
744bbe
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+ *
744bbe
+ * This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+ *
744bbe
+ * See the COPYRIGHT file distributed with this work for additional
744bbe
+ * information regarding copyright ownership.
744bbe
+ */
744bbe
+
744bbe
+options {
744bbe
+	query-source address 10.53.0.9;
744bbe
+	notify-source 10.53.0.9;
744bbe
+	transfer-source 10.53.0.9;
744bbe
+	port @PORT@;
744bbe
+	pid-file "named.pid";
744bbe
+	listen-on { 10.53.0.9; };
744bbe
+	listen-on-v6 { none; };
744bbe
+	dnssec-validation no;
744bbe
+	edns-udp-size 1232;
744bbe
+};
744bbe
+
744bbe
+key rndc_key {
744bbe
+	secret "1234abcd8765";
744bbe
+	algorithm hmac-sha256;
744bbe
+};
744bbe
+
744bbe
+controls {
744bbe
+	inet 10.53.0.9 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
744bbe
+};
744bbe
+
744bbe
+server 10.53.0.10 {
744bbe
+	edns no;
744bbe
+};
744bbe
+
744bbe
+server 10.53.0.11 {
744bbe
+	edns no;
744bbe
+};
744bbe
+
744bbe
+zone "." {
744bbe
+	type hint;
744bbe
+	file "root.db";
744bbe
+};
744bbe
+
744bbe
+zone "attacksecuredomain.net." {
744bbe
+	type forward;
744bbe
+	forward only;
744bbe
+	forwarders { 10.53.0.10; };
744bbe
+};
744bbe
+
744bbe
+zone "attacksecuredomain.net2." {
744bbe
+	type forward;
744bbe
+	forward only;
744bbe
+	forwarders { 10.53.0.10; };
744bbe
+};
744bbe
+
744bbe
+zone "attacksecuredomain.net3." {
744bbe
+	type forward;
744bbe
+	forward only;
744bbe
+	forwarders { 10.53.0.11; };
744bbe
+};
744bbe
+
744bbe
+zone "local.net." {
744bbe
+	type master;
744bbe
+	file "local.net.db";
744bbe
+	forwarders {};
744bbe
+};
744bbe
diff --git a/bin/tests/system/forward/ns9/named3.conf.in b/bin/tests/system/forward/ns9/named3.conf.in
744bbe
new file mode 100644
744bbe
index 0000000000..1e70d1ae51
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns9/named3.conf.in
744bbe
@@ -0,0 +1,48 @@
744bbe
+/*
744bbe
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+ *
744bbe
+ * This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+ *
744bbe
+ * See the COPYRIGHT file distributed with this work for additional
744bbe
+ * information regarding copyright ownership.
744bbe
+ */
744bbe
+
744bbe
+options {
744bbe
+	query-source address 10.53.0.9;
744bbe
+	notify-source 10.53.0.9;
744bbe
+	transfer-source 10.53.0.9;
744bbe
+	port @PORT@;
744bbe
+	pid-file "named.pid";
744bbe
+	listen-on { 10.53.0.9; };
744bbe
+	listen-on-v6 { none; };
744bbe
+	dnssec-validation no;
744bbe
+	edns-udp-size 1232;
744bbe
+	forward only;
744bbe
+	forwarders { 10.53.0.10; };
744bbe
+};
744bbe
+
744bbe
+key rndc_key {
744bbe
+	secret "1234abcd8765";
744bbe
+	algorithm hmac-sha256;
744bbe
+};
744bbe
+
744bbe
+controls {
744bbe
+	inet 10.53.0.9 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
744bbe
+};
744bbe
+
744bbe
+server 10.53.0.10 {
744bbe
+	edns no;
744bbe
+};
744bbe
+
744bbe
+zone "." {
744bbe
+	type hint;
744bbe
+	file "root.db";
744bbe
+};
744bbe
+
744bbe
+zone "local.net." {
744bbe
+	type master;
744bbe
+	file "local.net.db";
744bbe
+	forwarders {};
744bbe
+};
744bbe
diff --git a/bin/tests/system/forward/ns9/named4.conf.in b/bin/tests/system/forward/ns9/named4.conf.in
744bbe
new file mode 100644
744bbe
index 0000000000..6f7b1075b5
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns9/named4.conf.in
744bbe
@@ -0,0 +1,45 @@
744bbe
+/*
744bbe
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+ *
744bbe
+ * This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+ *
744bbe
+ * See the COPYRIGHT file distributed with this work for additional
744bbe
+ * information regarding copyright ownership.
744bbe
+ */
744bbe
+
744bbe
+options {
744bbe
+	query-source address 10.53.0.9;
744bbe
+	notify-source 10.53.0.9;
744bbe
+	transfer-source 10.53.0.9;
744bbe
+	port @PORT@;
744bbe
+	pid-file "named.pid";
744bbe
+	listen-on { 10.53.0.9; };
744bbe
+	listen-on-v6 { none; };
744bbe
+	dnssec-validation no;
744bbe
+	edns-udp-size 1232;
744bbe
+};
744bbe
+
744bbe
+key rndc_key {
744bbe
+	secret "1234abcd8765";
744bbe
+	algorithm hmac-sha256;
744bbe
+};
744bbe
+
744bbe
+controls {
744bbe
+	inet 10.53.0.9 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
744bbe
+};
744bbe
+
744bbe
+server 10.53.0.10 {
744bbe
+	edns no;
744bbe
+};
744bbe
+
744bbe
+zone "." {
744bbe
+	type hint;
744bbe
+	file "root.db";
744bbe
+};
744bbe
+
744bbe
+zone "local.tld." {
744bbe
+	type master;
744bbe
+	file "local.tld.db";
744bbe
+};
744bbe
diff --git a/bin/tests/system/forward/ns9/root.db b/bin/tests/system/forward/ns9/root.db
744bbe
new file mode 100644
744bbe
index 0000000000..4f30322270
744bbe
--- /dev/null
744bbe
+++ b/bin/tests/system/forward/ns9/root.db
744bbe
@@ -0,0 +1,11 @@
744bbe
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
744bbe
+;
744bbe
+; This Source Code Form is subject to the terms of the Mozilla Public
744bbe
+; License, v. 2.0. If a copy of the MPL was not distributed with this
744bbe
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
744bbe
+;
744bbe
+; See the COPYRIGHT file distributed with this work for additional
744bbe
+; information regarding copyright ownership.
744bbe
+
744bbe
+.			NS	a.root-servers.nil.
744bbe
+a.root-servers.nil.	A	10.53.0.1
744bbe
diff --git a/bin/tests/system/forward/prereq.sh b/bin/tests/system/forward/prereq.sh
744bbe
index d2ca8fc2bf..53fb5817df 100644
744bbe
--- a/bin/tests/system/forward/prereq.sh
744bbe
+++ b/bin/tests/system/forward/prereq.sh
744bbe
@@ -12,6 +12,20 @@
744bbe
 SYSTEMTESTTOP=..
744bbe
 . $SYSTEMTESTTOP/conf.sh
744bbe
 
744bbe
+if test -n "$PYTHON"
744bbe
+then
744bbe
+    if $PYTHON -c "import dns" 2> /dev/null
744bbe
+    then
744bbe
+        :
744bbe
+    else
744bbe
+        echo_i "This test requires the dnspython module." >&2
744bbe
+        exit 1
744bbe
+    fi
744bbe
+else
744bbe
+    echo_i "This test requires Python and the dnspython module." >&2
744bbe
+    exit 1
744bbe
+fi
744bbe
+
744bbe
 if $PERL -e 'use Net::DNS;' 2>/dev/null
744bbe
 then
744bbe
     :
744bbe
diff --git a/bin/tests/system/forward/setup.sh b/bin/tests/system/forward/setup.sh
744bbe
index 87452b9a88..18e81d277d 100644
744bbe
--- a/bin/tests/system/forward/setup.sh
744bbe
+++ b/bin/tests/system/forward/setup.sh
744bbe
@@ -18,3 +18,6 @@ copy_setports ns3/named.conf.in ns3/named.conf
744bbe
 copy_setports ns4/named.conf.in ns4/named.conf
744bbe
 copy_setports ns5/named.conf.in ns5/named.conf
744bbe
 copy_setports ns7/named.conf.in ns7/named.conf
744bbe
+copy_setports ns8/named.conf.in ns8/named.conf
744bbe
+copy_setports ns9/named1.conf.in ns9/named.conf
744bbe
+copy_setports ns10/named.conf.in ns10/named.conf
744bbe
diff --git a/bin/tests/system/forward/tests.sh b/bin/tests/system/forward/tests.sh
744bbe
index e3549c5bc7..ce9b309a27 100644
744bbe
--- a/bin/tests/system/forward/tests.sh
744bbe
+++ b/bin/tests/system/forward/tests.sh
744bbe
@@ -19,6 +19,10 @@ sendcmd() (
744bbe
 	"$PERL" ../send.pl 10.53.0.6 "$EXTRAPORT1"
744bbe
 )
744bbe
 
744bbe
+rndccmd() {
744bbe
+    "$RNDC" -c ../common/rndc.conf -p "$CONTROLPORT" -s "$@"
744bbe
+}
744bbe
+
744bbe
 root=10.53.0.1
744bbe
 hidden=10.53.0.2
744bbe
 f1=10.53.0.3
744bbe
@@ -223,5 +227,127 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
744bbe
 status=$((status+ret))
744bbe
 
744bbe
 
744bbe
+#
744bbe
+# Check various spoofed response scenarios. The same tests will be
744bbe
+# run twice, with "forward first" and "forward only" configurations.
744bbe
+#
744bbe
+run_spooftests () {
744bbe
+    n=$((n+1))
744bbe
+    echo_i "checking spoofed response scenario 1 - out of bailiwick NS ($n)"
744bbe
+    ret=0
744bbe
+    # prime
744bbe
+    dig_with_opts @10.53.0.9 attackSecureDomain.net > dig.out.$n.prime || ret=1
744bbe
+    # check 'net' is not poisoned.
744bbe
+    dig_with_opts @10.53.0.9 diditwork.net. TXT > dig.out.$n.net || ret=1
744bbe
+    grep '^diditwork\.net\..*TXT.*"recursed"' dig.out.$n.net > /dev/null || ret=1
744bbe
+    # check 'sub.local.net' is not poisoned.
744bbe
+    dig_with_opts @10.53.0.9 sub.local.net TXT > dig.out.$n.sub || ret=1
744bbe
+    grep '^sub\.local\.net\..*TXT.*"recursed"' dig.out.$n.sub > /dev/null || ret=1
744bbe
+    if [ $ret != 0 ]; then echo_i "failed"; fi
744bbe
+    status=$((status+ret))
744bbe
+
744bbe
+    n=$((n+1))
744bbe
+    echo_i "checking spoofed response scenario 2 - inject DNAME/net2. ($n)"
744bbe
+    ret=0
744bbe
+    # prime
744bbe
+    dig_with_opts @10.53.0.9 attackSecureDomain.net2 > dig.out.$n.prime || ret=1
744bbe
+    # check that net2/DNAME is not cached
744bbe
+    dig_with_opts @10.53.0.9 net2. DNAME > dig.out.$n.net2 || ret=1
744bbe
+    grep "ANSWER: 0," dig.out.$n.net2 > /dev/null || ret=1
744bbe
+    grep "status: NXDOMAIN" dig.out.$n.net2 > /dev/null || ret=1
744bbe
+    if [ $ret != 0 ]; then echo_i "failed"; fi
744bbe
+    status=$((status+ret))
744bbe
+
744bbe
+    n=$((n+1))
744bbe
+    echo_i "checking spoofed response scenario 3 - extra answer ($n)"
744bbe
+    ret=0
744bbe
+    # prime
744bbe
+    dig_with_opts @10.53.0.9 attackSecureDomain.net3 > dig.out.$n.prime || ret=1
744bbe
+    # check extra net3 records are not cached
744bbe
+    rndccmd 10.53.0.9 dumpdb -cache 2>&1 | sed 's/^/ns9 /' | cat_i
744bbe
+    for try in 1 2 3 4 5; do
744bbe
+        lines=$(grep "net3" ns9/named_dump.db | wc -l)
744bbe
+        if [ ${lines} -eq 0 ]; then
744bbe
+                sleep 1
744bbe
+                continue
744bbe
+        fi
744bbe
+        [ ${lines} -eq 1 ] || ret=1
744bbe
+        grep -q '^attackSecureDomain.net3' ns9/named_dump.db || ret=1
744bbe
+        grep -q '^local.net3' ns9/named_dump.db && ret=1
744bbe
+    done
744bbe
+    if [ $ret != 0 ]; then echo_i "failed"; fi
744bbe
+    status=$((status+ret))
744bbe
+}
744bbe
+
744bbe
+echo_i "checking spoofed response scenarios with forward first zones"
744bbe
+run_spooftests
744bbe
+
744bbe
+copy_setports ns9/named2.conf.in ns9/named.conf
744bbe
+rndccmd 10.53.0.9 reconfig 2>&1 | sed 's/^/ns3 /' | cat_i
744bbe
+rndccmd 10.53.0.9 flush 2>&1 | sed 's/^/ns3 /' | cat_i
744bbe
+sleep 1
744bbe
+
744bbe
+echo_i "rechecking spoofed response scenarios with forward only zones"
744bbe
+run_spooftests
744bbe
+
744bbe
+#
744bbe
+# This scenario expects the spoofed response to succeed. The tests are
744bbe
+# similar to the ones above, but not identical.
744bbe
+#
744bbe
+echo_i "rechecking spoofed response scenarios with 'forward only' set globally"
744bbe
+copy_setports ns9/named3.conf.in ns9/named.conf
744bbe
+rndccmd 10.53.0.9 reconfig 2>&1 | sed 's/^/ns3 /' | cat_i
744bbe
+rndccmd 10.53.0.9 flush 2>&1 | sed 's/^/ns3 /' | cat_i
744bbe
+sleep 1
744bbe
+
744bbe
+n=$((n+1))
744bbe
+echo_i "checking spoofed response scenario 1 - out of bailiwick NS ($n)"
744bbe
+ret=0
744bbe
+# prime
744bbe
+dig_with_opts @10.53.0.9 attackSecureDomain.net > dig.out.$n.prime || ret=1
744bbe
+# check 'net' is poisoned.
744bbe
+dig_with_opts @10.53.0.9 diditwork.net. TXT > dig.out.$n.net || ret=1
744bbe
+grep '^didItWork\.net\..*TXT.*"if you can see this record the attack worked"' dig.out.$n.net > /dev/null || ret=1
744bbe
+# check 'sub.local.net' is poisoned.
744bbe
+dig_with_opts @10.53.0.9 sub.local.net TXT > dig.out.$n.sub || ret=1
744bbe
+grep '^sub\.local\.net\..*TXT.*"if you see this attacker overrode local delegation"' dig.out.$n.sub > /dev/null || ret=1
744bbe
+if [ $ret != 0 ]; then echo_i "failed"; fi
744bbe
+status=$((status+ret))
744bbe
+
744bbe
+n=$((n+1))
744bbe
+echo_i "checking spoofed response scenario 2 - inject DNAME/net2. ($n)"
744bbe
+ret=0
744bbe
+# prime
744bbe
+dig_with_opts @10.53.0.9 attackSecureDomain.net2 > dig.out.$n.prime || ret=1
744bbe
+# check that net2/DNAME is cached
744bbe
+dig_with_opts @10.53.0.9 net2. DNAME > dig.out.$n.net2 || ret=1
744bbe
+grep "ANSWER: 1," dig.out.$n.net2 > /dev/null || ret=1
744bbe
+grep "net2\..*IN.DNAME.net\.example\.lll\." dig.out.$n.net2 > /dev/null || ret=1
744bbe
+if [ $ret != 0 ]; then echo_i "failed"; fi
744bbe
+status=$((status+ret))
744bbe
+
744bbe
+#
744bbe
+# This test doesn't use any forwarder clauses but is here because it
744bbe
+# is similar to forwarders, as the set of servers that can populate
744bbe
+# the namespace is defined by the zone content.
744bbe
+#
744bbe
+echo_i "rechecking spoofed response scenarios glue below local zone"
744bbe
+copy_setports ns9/named4.conf.in ns9/named.conf
744bbe
+rndccmd 10.53.0.9 reconfig 2>&1 | sed 's/^/ns3 /' | cat_i
744bbe
+rndccmd 10.53.0.9 flush 2>&1 | sed 's/^/ns3 /' | cat_i
744bbe
+sleep 1
744bbe
+
744bbe
+n=$((n+1))
744bbe
+echo_i "checking sibling glue below zone ($n)"
744bbe
+ret=0
744bbe
+# prime
744bbe
+dig_with_opts @10.53.0.9 sibling.tld > dig.out.$n.prime || ret=1
744bbe
+# check for glue A record for sub.local.tld is not used
744bbe
+dig_with_opts @10.53.0.9 sub.local.tld TXT > dig.out.$n.sub || ret=1
744bbe
+grep "ANSWER: 1," dig.out.$n.sub > /dev/null || ret=1
744bbe
+grep 'sub\.local\.tld\..*IN.TXT."good"$' dig.out.$n.sub > /dev/null || ret=1
744bbe
+if [ $ret != 0 ]; then echo_i "failed"; fi
744bbe
+status=$((status+ret))
744bbe
+
744bbe
 echo_i "exit status: $status"
744bbe
 [ $status -eq 0 ] || exit 1
744bbe
diff --git a/bin/tests/system/ifconfig.sh b/bin/tests/system/ifconfig.sh
744bbe
index d0eb9fa61d..8b9212c3e0 100755
744bbe
--- a/bin/tests/system/ifconfig.sh
744bbe
+++ b/bin/tests/system/ifconfig.sh
744bbe
@@ -12,10 +12,10 @@
744bbe
 #
744bbe
 # Set up interface aliases for bind9 system tests.
744bbe
 #
744bbe
-# IPv4: 10.53.0.{1..10}				RFC 1918
744bbe
+# IPv4: 10.53.0.{1..11}				RFC 1918
744bbe
 #       10.53.1.{1..2}
744bbe
 #       10.53.2.{1..2}
744bbe
-# IPv6: fd92:7065:b8e:ffff::{1..10}		ULA
744bbe
+# IPv6: fd92:7065:b8e:ffff::{1..11}		ULA
744bbe
 #       fd92:7065:b8e:99ff::{1..2}
744bbe
 #       fd92:7065:b8e:ff::{1..2}
744bbe
 #
744bbe
@@ -65,7 +65,7 @@ case "$1" in
744bbe
 		  2) ipv6="00" ;;
744bbe
 		  *) ipv6="" ;;
744bbe
 		esac
744bbe
-		for ns in 1 2 3 4 5 6 7 8 9 10
744bbe
+		for ns in 1 2 3 4 5 6 7 8 9 10 11
744bbe
 		do
744bbe
 			[ $i -gt 0 -a $ns -gt 2 ] && break
744bbe
 			int=`expr $i \* 10 + $ns`
744bbe
@@ -165,7 +165,7 @@ case "$1" in
744bbe
 		  2) ipv6="00" ;;
744bbe
 		  *) ipv6="" ;;
744bbe
 		esac
744bbe
-		for ns in 10 9 8 7 6 5 4 3 2 1
744bbe
+		for ns in 11 10 9 8 7 6 5 4 3 2 1
744bbe
 		do
744bbe
 			[ $i -gt 0 -a $ns -gt 2 ] && continue
744bbe
 			int=`expr $i \* 10 + $ns - 1`
744bbe
-- 
744bbe
2.34.1
744bbe