summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>2018-07-30 14:19:57 +0200
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>2018-07-30 14:19:57 +0200
commit9f4e7daedbd5572da2e5758e2cfb0362c99785e2 (patch)
treef999369492bce0c07ccbb38dd25196d56b14f469
parent1dfc7ac5bfafe2cc7a081c90333ac65080736f93 (diff)
downloadldns-9f4e7daedbd5572da2e5758e2cfb0362c99785e2.tar.gz
Fix time sensitive TSIG compare vulnerability.
-rw-r--r--Changelog1
-rw-r--r--tsig.c8
2 files changed, 8 insertions, 1 deletions
diff --git a/Changelog b/Changelog
index 67afe939..7b229712 100644
--- a/Changelog
+++ b/Changelog
@@ -28,6 +28,7 @@
Thanks James Raftery
* ED25519 and ED448 support.
* ldns-notify: can have IPv6 address as argument.
+ * Fix time sensitive TSIG compare vulnerability.
1.7.0 2016-12-20
* Fix lookup of relative names in ldns_resolver_search.
diff --git a/tsig.c b/tsig.c
index 62776f06..458861a1 100644
--- a/tsig.c
+++ b/tsig.c
@@ -349,7 +349,13 @@ ldns_pkt_tsig_verify_next(ldns_pkt *pkt, const uint8_t *wire, size_t wirelen, co
ldns_rdf_deep_free(key_name_rdf);
- if (ldns_rdf_compare(pkt_mac_rdf, my_mac_rdf) == 0) {
+ if( ldns_rdf_size(pkt_mac_rdf) != ldns_rdf_size(my_mac_rdf)) {
+ ldns_rdf_deep_free(my_mac_rdf);
+ return false;
+ }
+ /* use time insensitive memory compare */
+ if(CRYPTO_memcmp(ldns_rdf_data(pkt_mac_rdf), ldns_rdf_data(my_mac_rdf),
+ ldns_rdf_size(my_mac_rdf)) == 0) {
ldns_rdf_deep_free(my_mac_rdf);
return true;
} else {