bcfc7f
From f6ca6392adf7f5a94c804d8a8a1233d90170f490 Mon Sep 17 00:00:00 2001
bcfc7f
From: Petr Mensik <pemensik@redhat.com>
bcfc7f
Date: Fri, 15 May 2020 14:56:33 +0200
bcfc7f
Subject: [PATCH] CVE-2020-8617
bcfc7f
bcfc7f
5390.	[security]	Replaying a TSIG BADTIME response as a request could
bcfc7f
			trigger an assertion failure. (CVE-2020-8617)
bcfc7f
			[GL #1703]
bcfc7f
---
bcfc7f
 lib/dns/tsig.c | 7 ++++---
bcfc7f
 1 file changed, 4 insertions(+), 3 deletions(-)
bcfc7f
bcfc7f
diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c
bcfc7f
index c6f9d1b..aee8eb0 100644
bcfc7f
--- a/lib/dns/tsig.c
bcfc7f
+++ b/lib/dns/tsig.c
bcfc7f
@@ -1431,8 +1431,9 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg,
bcfc7f
 			goto cleanup_context;
bcfc7f
 		}
bcfc7f
 		msg->verified_sig = 1;
bcfc7f
-	} else if (tsig.error != dns_tsigerror_badsig &&
bcfc7f
-		   tsig.error != dns_tsigerror_badkey) {
bcfc7f
+	} else if (!response || (tsig.error != dns_tsigerror_badsig &&
bcfc7f
+				 tsig.error != dns_tsigerror_badkey))
bcfc7f
+	{
bcfc7f
 		tsig_log(msg->tsigkey, 2, "signature was empty");
bcfc7f
 		return (DNS_R_TSIGVERIFYFAILURE);
bcfc7f
 	}
bcfc7f
@@ -1488,7 +1489,7 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg,
bcfc7f
 		}
bcfc7f
 	}
bcfc7f
 
bcfc7f
-	if (tsig.error != dns_rcode_noerror) {
bcfc7f
+	if (response && tsig.error != dns_rcode_noerror) {
bcfc7f
 		msg->tsigstatus = tsig.error;
bcfc7f
 		if (tsig.error == dns_tsigerror_badtime)
bcfc7f
 			ret = DNS_R_CLOCKSKEW;
bcfc7f
-- 
bcfc7f
2.21.1
bcfc7f