zone "evil-cname" policy cname a12.tld2. ede blocked;
zone "wild-cname" ede blocked;
zone "slow-rpz";
+ zone "outofzone.tld2";
}
add-soa yes
min-ns-dots 0
notify no;
};
+/*
+ * A policy zone holding a record from outside the zone. ns2 does not
+ * serve it, so "outofzone.db" is never replaced by a transfer.
+ */
+zone "outofzone.tld2." {
+ type secondary;
+ file "outofzone.db";
+ masterfile-format text;
+ primaries { 10.53.0.2; };
+ notify no;
+};
+
zone "stub." {
type stub;
primaries { 10.53.0.2; };
--- /dev/null
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; SPDX-License-Identifier: MPL-2.0
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
+;
+; See the COPYRIGHT file distributed with this work for additional
+; information regarding copyright ownership.
+
+; A policy zone as a secondary would have written it out after a transfer
+; that carried a record from outside the zone. The zone is a secondary so
+; that this file is loaded the way a secondary loads its own copy of a
+; transferred zone; the out-of-zone check in lib/dns/master.c only applies
+; to primaries.
+
+$TTL 300
+@ SOA ns.tld3. hostmaster.ns.tld3. ( 1 3600 1200 2419200 60 )
+ NS ns.tld3.
+
+; Two labels, fewer than the three of the origin, so stripping the origin
+; from it used to underflow an unsigned label count in name2data().
+com. CNAME .
+
+; An ordinary trigger, so the test can tell that the rest of the zone is
+; still loaded after the record above has been rejected. It is never
+; queried, so it cannot disturb the other checks in this test.
+never-queried.example CNAME .
cp ns5/fast-expire.db.in ns5/fast-expire.db
cp ns5/expire.conf.in ns5/expire.conf
+# a policy zone holding a record from outside the zone
+cp ns3/outofzone.db.in ns3/outofzone.db
+
# $1=directory
# $2=domain name
# $3=input zone file
test -z "$HAVE_CORE" || setret "found $HAVE_CORE; memory leak?"
fi
-# look for complaints from lib/dns/rpz.c and bin/name/query.c
+# look for complaints from lib/dns/rpz.c and bin/name/query.c, except the
+# one the outofzone.tld2 policy zone is there to provoke
+EXPECTED='invalid rpz owner name "com"'
for runfile in ns*/named.run; do
- EMSGS=$(nextpart $runfile | grep -E -l 'invalid rpz|rpz.*failed' || true)
+ EMSGS=$(nextpart $runfile | grep -Fv "$EXPECTED" \
+ | grep -E -l 'invalid rpz|rpz.*failed' || true)
if test -n "$EMSGS"; then
setret "error messages in $runfile starting with:"
- grep -E 'invalid rpz|rpz.*failed' ns*/named.run \
+ grep -E 'invalid rpz|rpz.*failed' ns*/named.run | grep -Fv "$EXPECTED" \
| sed -e '10,$d' -e 's/^//' | cat_i
fi
done
--- /dev/null
+#!/usr/bin/python3
+
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+from isctest.instance import NamedInstance
+
+
+def test_rpz_out_of_zone_owner_name(ns3: NamedInstance) -> None:
+ """
+ ns3 loads a policy zone holding "com.", whose two labels are fewer than
+ the three of the "outofzone.tld2." origin that gets stripped from an
+ owner name to build the trigger name. That used to underflow an
+ unsigned label count and fail an assertion, taking named down as the
+ policy zone was loaded - so reaching this test at all is most of the
+ check.
+ """
+ assert 'invalid rpz owner name "com"; not within the policy zone' in ns3.log
+
+ # Only the record above was dropped; the rest of the zone still loads.
+ assert (
+ "rpz: outofzone.tld2: adding node never-queried.example.outofzone.tld2"
+ in ns3.log
+ )
"ns3/mixed-case-rpz.db",
"ns3/named.conf.tmp",
"ns3/named.stats",
+ "ns3/outofzone.db",
"ns3/slow-rpz.db",
"ns3/wild-cname.db",
"ns5/bl.db",