]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
2831. [security] Do not attempt to validate or cache
authorEvan Hunt <each@isc.org>
Thu, 7 Jan 2010 16:48:23 +0000 (16:48 +0000)
committerEvan Hunt <each@isc.org>
Thu, 7 Jan 2010 16:48:23 +0000 (16:48 +0000)
out-of-bailiwick data returned with a secure
answer; it must be re-fetched from its original
source and validated in that context. [RT #20819]

CHANGES
bin/tests/system/pending/ns1/root.db.in
bin/tests/system/pending/ns1/sign.sh
bin/tests/system/pending/ns2/example.db.in
bin/tests/system/pending/ns2/forgery.db [new file with mode: 0644]
bin/tests/system/pending/ns2/named.conf
bin/tests/system/pending/ns2/sign.sh
bin/tests/system/pending/tests.sh
lib/dns/resolver.c

diff --git a/CHANGES b/CHANGES
index 0986721973e4234ea862867138e4277d599d67f6..db9a6d23dc7a1975e533e3a5fc89ddedc87db851 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+2831.  [security]      Do not attempt to validate or cache
+                       out-of-bailiwick data returned with a secure
+                       answer; it must be re-fetched from its original
+                       source and validated in that context. [RT #20819]
+
 2830.  [bug]           Changing the OPTOUT setting could take multiple
                        passes. [RT #20813]
 
index 41d868142d228ac27fdcc7183c8f28cdf0b62649..7dc3bdb73646a24df10ad3e20377fe77fb4241c5 100644 (file)
@@ -12,7 +12,7 @@
 ; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 ; PERFORMANCE OF THIS SOFTWARE.
 
-; $Id: root.db.in,v 1.4 2009/12/30 08:02:22 jinmei Exp $
+; $Id: root.db.in,v 1.5 2010/01/07 16:48:23 each Exp $
 
 $TTL 30
 .                      IN SOA  marka.isc.org. a.root.servers.nil. (
@@ -31,3 +31,4 @@ example.com.          NS      ns2.example.com.
 ns2.example.com.       A       10.53.0.2
 hostile.               NS      ns3.hostile.
 ns3.hostile.           A       10.53.0.3
+nice.good.             A       10.10.10.10
index 6a76323e09623f0b4e03373f9c76ae9ecc5cdd37..5188fe6b69c630ca10227a6c762c1d7e9fa32a10 100644 (file)
@@ -14,7 +14,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: sign.sh,v 1.3 2009/12/30 08:02:22 jinmei Exp $
+# $Id: sign.sh,v 1.4 2010/01/07 16:48:23 each Exp $
 
 SYSTEMTESTTOP=../..
 . $SYSTEMTESTTOP/conf.sh
@@ -34,7 +34,7 @@ keyname1=`$KEYGEN -q -r $RANDFILE -a RSASHA256 -b 1024 -n zone $zone`
 keyname2=`$KEYGEN -q -r $RANDFILE -a RSASHA256 -b 2048 -f KSK -n zone $zone`
 cat $infile $keyname1.key $keyname2.key > $zonefile
 
-$SIGNER -g -r $RANDFILE -o $zone $zonefile > /dev/null
+$SIGNER -g -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
 
 # Configure the resolving server with a trusted key.
 
index ca0d596b21133fd50a8dbefa80fa0698c94a213f..c5ee97767647f048ba3f517d4827b0de1c78c884 100644 (file)
 ; OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 ; PERFORMANCE OF THIS SOFTWARE.
 
-; $Id: example.db.in,v 1.2 2009/11/17 23:55:18 marka Exp $
+; $Id: example.db.in,v 1.3 2010/01/07 16:48:23 each Exp $
 
 $TTL 30
+$ORIGIN example.
 @                      IN SOA  mname1. . (
                                2009110300 ; serial
                                20         ; refresh (20 seconds)
@@ -26,3 +27,5 @@ $TTL 30
                        MX      10 mail
 ns2                    A       10.53.0.2
 mail                   A       10.0.0.2
+bad                    CNAME   nice.good.
+worse                   A       6.6.6.6
diff --git a/bin/tests/system/pending/ns2/forgery.db b/bin/tests/system/pending/ns2/forgery.db
new file mode 100644 (file)
index 0000000..e320ab1
--- /dev/null
@@ -0,0 +1,13 @@
+$TTL 30
+$ORIGIN good.
+@                      IN SOA  mname1. . (
+                               2009110300 ; serial
+                               20         ; refresh (20 seconds)
+                               20         ; retry (20 seconds)
+                               1814400    ; expire (3 weeks)
+                               3600       ; minimum (1 hour)
+                               )
+                       NS      ns2
+ns2                    A       10.53.0.2
+
+nice.good.             CNAME   worse.example.
index 7cc1ffbc632c3b3da28e89472413d4e815c9f5c7..811bc8d39fd1c7e8abb4325531eea49d7e502235 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: named.conf,v 1.4 2009/12/30 08:02:22 jinmei Exp $ */
+/* $Id: named.conf,v 1.5 2010/01/07 16:48:23 each Exp $ */
 
 // NS2
 
@@ -51,3 +51,9 @@ zone "example.com" {
        file "example.com.db.signed";
        allow-update { 10.53.0.0/8; };
 };
+
+zone "good" {
+        type master;
+        file "forgery.db";
+        allow-query { any; };
+};
index 626927aa06b3f579f9b16dadc94252cf43a91c6a..b5390f5dd6c3d17544b6171da36436627729c454 100644 (file)
@@ -14,7 +14,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: sign.sh,v 1.4 2009/12/30 08:02:22 jinmei Exp $
+# $Id: sign.sh,v 1.5 2010/01/07 16:48:23 each Exp $
 
 SYSTEMTESTTOP=../..
 . $SYSTEMTESTTOP/conf.sh
@@ -31,5 +31,5 @@ for domain in example example.com; do
 
        cat $infile $keyname1.key $keyname2.key >$zonefile
 
-       $SIGNER -r $RANDFILE -o $zone $zonefile > /dev/null
+       $SIGNER -r $RANDFILE -o $zone $zonefile > /dev/null 2>&1
 done
index c27b072a01c995f18d72d2412b406a504e24dcdd..464bf6d8641d69b35a867c0ab38f3963a23f7521 100644 (file)
@@ -14,7 +14,7 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: tests.sh,v 1.4 2009/12/30 08:02:22 jinmei Exp $
+# $Id: tests.sh,v 1.5 2010/01/07 16:48:23 each Exp $
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
@@ -158,5 +158,26 @@ test "$ans" = "$expect" || ret=1
 test $ret = 0 || echo I:failed, got "'""$ans""'", expected "'""$expect""'"
 status=`expr $status + $ret`
 
+#
+# Try to fool the resolver with an out-of-bailiwick CNAME
+#
+echo I:Trying to Prime out-of-bailiwick pending answer with CD
+ret=0
+expect="10.10.10.10"
+ans=`$DIG $DIGOPTS_CD @10.53.0.4 bad.example. A` || ret=1
+ans=`echo $ans | awk '{print $NF}'`
+test "$ans" = "$expect" || ret=1
+test $ret = 0 || echo I:failed, got "'""$ans""'", expected "'""$expect""'"
+status=`expr $status + $ret`
+
+echo I:Confirming the out-of-bailiwick answer is not cached or reused with CD
+ret=0
+expect="10.10.10.10"
+ans=`$DIG $DIGOPTS_CD @10.53.0.4 nice.good. A` || ret=1
+ans=`echo $ans | awk '{print $NF}'`
+test "$ans" = "$expect" || ret=1
+test $ret = 0 || echo I:failed, got "'""$ans""'", expected "'""$expect""'"
+status=`expr $status + $ret`
+
 echo "I:exit status: $status"
 exit $status
index 4381d039135c36ee2c24e04f2354924e6a440631..6dc57916221ab0961acda3fbbed2d4bb39e13037 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: resolver.c,v 1.413 2009/11/18 23:48:07 tbox Exp $ */
+/* $Id: resolver.c,v 1.414 2010/01/07 16:48:23 each Exp $ */
 
 /*! \file */
 
@@ -4359,11 +4359,19 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, dns_adbaddrinfo_t *addrinfo,
                        rdataset->ttl = res->view->maxcachettl;
 
                /*
-                * If this rrset is in a secure domain, do DNSSEC validation
-                * for it, unless it is glue.
+                * If this RRset is in a secure domain, is in bailiwick,
+                * and is not glue, attempt DNSSEC validation.  (We do not
+                * attempt to validate glue or out-of-bailiwick data--even
+                * though there might be some performance benefit to doing
+                * so--because it makes it simpler and safer to ensure that
+                * records from a secure domain are only cached if validated
+                * within the context of a query to the domain that owns
+                * them.)
                 */
-               if (secure_domain && rdataset->trust != dns_trust_glue) {
+               if (secure_domain && rdataset->trust != dns_trust_glue &&
+                   !EXTERNAL(rdataset)) {
                        dns_trust_t trust;
+
                        /*
                         * RRSIGs are validated as part of validating the
                         * type they cover.
@@ -4400,22 +4408,6 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, dns_adbaddrinfo_t *addrinfo,
                        }
 
                        /*
-                        * Reject out of bailiwick additional records
-                        * without RRSIGs as they can't possibly validate
-                        * as "secure" and as we will never never want to
-                        * store these as "answers" after validation.
-                        */
-                       if (rdataset->trust == dns_trust_additional &&
-                           sigrdataset == NULL && EXTERNAL(rdataset))
-                               continue;
-
-                       /*
-                        * XXXMPA: If we store as "answer" after validating
-                        * then we need to do bailiwick processing and
-                        * also need to track whether RRsets are in or
-                        * out of bailiwick.  This will require a another
-                        * pending trust level.
-                        *
                         * Cache this rdataset/sigrdataset pair as
                         * pending data.  Track whether it was additional
                         * or not.
@@ -5784,9 +5776,7 @@ answer_response(fetchctx_t *fctx) {
                                                /*
                                                 * This data is outside of
                                                 * our query domain, and
-                                                * may only be cached if it
-                                                * comes from a secure zone
-                                                * and validates.
+                                                * may not be cached.
                                                 */
                                                rdataset->attributes |=
                                                    DNS_RDATASETATTR_EXTERNAL;