From c68ab952ed3344621fce70eec846944d1b46d4fb Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Sun, 14 Jun 2015 21:14:05 +0300 Subject: [PATCH] Check for correct TSIG key for domain --- pdns/packethandler.cc | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index d6217e412..cc028dbc4 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -832,18 +832,35 @@ int PacketHandler::processNotify(DNSPacket *p) { /* now what? was this notification from an approved address? + was this notification approved by TSIG? We determine our internal SOA id (via UeberBackend) We determine the SOA at our (known) master if master is higher -> do stuff */ + vector meta; + string tsigkeyname; + if(!::arg().mustDo("slave")) { L<qdomain<<" from "<getRemote()<<" but slave support is disabled in the configuration"<d_remote )) { - L<qdomain<<" from "<getRemote()<<" but remote is not in allow-notify-from"<d_remote ) || p->d_havetsig) { + if (p->d_havetsig) { + TSIGRecordContent trc; + UeberBackend B; + string tsigsecret; + + if (!checkForCorrectTSIG(p, &B, &tsigkeyname, &tsigsecret, &trc)) { + L<qdomain<<" from "<getRemote()<<" but TSIG key '"<qdomain<<" from "<getRemote()<<", allowed by TSIG key '"<qdomain<<" from "<getRemote()<<" but remote is not permitted by TSIG or allow-notify-from"<qdomain<<" from "<getRemote()<<" for which we are not authoritative"<qdomain,"AXFR-MASTER-TSIG",meta) && meta.size() > 0) { + if (!p->d_havetsig || meta[0] != tsigkeyname) { + L<qdomain<<" from "<getRemote()<<": expected TSIG key '"<getRemote())) { L<qdomain<<" from trusted-notification-proxy "<< p->getRemote()<