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