From: Matthijs Mekking Date: Wed, 30 Jan 2019 10:12:49 +0000 (+0100) Subject: Harden checks X-Git-Tag: v9.13.6~22^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b05a095a3e5c1dae6f618bc89330565b26ba3f9b;p=thirdparty%2Fbind9.git Harden checks --- diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index be4f2668d9e..20fc75897fb 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -625,12 +625,11 @@ process_gsstkey(dns_message_t *msg, dns_name_t *name, dns_rdata_tkey_t *tkeyin, tkey_log("process_gsstkey(): dns_tsigerror_noerror"); /* XXXSRA */ /* - * We found a TKEY to respond with. We don't know if - * the request is TSIG signed, but if it is not we need to make - * sure the response is signed (RFC 2845 secton 2.2). + * We found a TKEY to respond with. If the request is not TSIG signed, + * we need to make sure the response is signed (see RFC 3645, Section + * 2.2). */ - - if (tsigkey != NULL) { + if (tsigkey != NULL && msg->tsigkey == NULL && msg->sig0key == NULL) { dns_message_settsigkey(msg, tsigkey); } diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index 79afd3f15c5..bb66c5f174f 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -778,7 +778,16 @@ dns_tsig_sign(dns_message_t *msg) { key = dns_message_gettsigkey(msg); REQUIRE(VALID_TSIG_KEY(key)); + /* + * If this is a response, there should be a TSIG in the query with the + * the exception if this is a TKEY request (see RFC 3645, Section 2.2). + */ response = is_response(msg); + if (response && msg->querytsig == NULL) { + if (msg->tkey != 1) { + return (DNS_R_EXPECTEDTSIG); + } + } mctx = msg->mctx;