]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove support for SIG(0) message verification
authorPetr Špaček <pspacek@isc.org>
Thu, 16 May 2024 10:10:41 +0000 (12:10 +0200)
committerNicki Křížek <nicki@isc.org>
Wed, 24 Jul 2024 10:15:21 +0000 (12:15 +0200)
(cherry picked from commit 857fd5c346e3309ee8e280c29174b46579af5a13)

bin/named/client.c
lib/dns/message.c

index 15fcfcd3c306755c80d90ed8e840d9401ab552b9..761d72a9b2a7d665de2a8937d8a04c2d59c942f5 100644 (file)
@@ -3012,6 +3012,12 @@ client_request(isc_task_t *task, isc_event_t *event) {
                ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
                              NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
                              "request is signed by a nonauthoritative key");
+       } else if (result == DNS_R_NOTVERIFIEDYET &&
+                  client->message->sig0 != NULL) {
+               ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
+                             NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
+                             "request has a SIG(0) signature but its support "
+                             "was removed (CVE-2024-1975)");
        } else {
                char tsigrcode[64];
                isc_buffer_t b;
index a44eb2d1e9588d8bbc68ac131d53a4289998babc..03ed2a178dc60bf3ebfd3919a2900d8965221ae7 100644 (file)
@@ -3373,102 +3373,24 @@ dns_message_dumpsig(dns_message_t *msg, char *txt1) {
 
 isc_result_t
 dns_message_checksig(dns_message_t *msg, dns_view_t *view) {
-       isc_buffer_t b, msgb;
+       isc_buffer_t msgb;
 
        REQUIRE(DNS_MESSAGE_VALID(msg));
 
-       if (msg->tsigkey == NULL && msg->tsig == NULL && msg->sig0 == NULL)
+       if (msg->tsigkey == NULL && msg->tsig == NULL) {
                return (ISC_R_SUCCESS);
+       }
 
        INSIST(msg->saved.base != NULL);
        isc_buffer_init(&msgb, msg->saved.base, msg->saved.length);
        isc_buffer_add(&msgb, msg->saved.length);
-       if (msg->tsigkey != NULL || msg->tsig != NULL) {
 #ifdef SKAN_MSG_DEBUG
-               dns_message_dumpsig(msg, "dns_message_checksig#1");
-#endif
-               if (view != NULL)
-                       return (dns_view_checksig(view, &msgb, msg));
-               else
-                       return (dns_tsig_verify(&msgb, msg, NULL, NULL));
+       dns_message_dumpsig(msg, "dns_message_checksig#1");
+#endif /* ifdef SKAN_MSG_DEBUG */
+       if (view != NULL) {
+               return (dns_view_checksig(view, &msgb, msg));
        } else {
-               dns_rdata_t rdata = DNS_RDATA_INIT;
-               dns_rdata_sig_t sig;
-               dns_rdataset_t keyset;
-               isc_result_t result;
-
-               result = dns_rdataset_first(msg->sig0);
-               INSIST(result == ISC_R_SUCCESS);
-               dns_rdataset_current(msg->sig0, &rdata);
-
-               /*
-                * This can occur when the message is a dynamic update, since
-                * the rdata length checking is relaxed.  This should not
-                * happen in a well-formed message, since the SIG(0) is only
-                * looked for in the additional section, and the dynamic update
-                * meta-records are in the prerequisite and update sections.
-                */
-               if (rdata.length == 0)
-                       return (ISC_R_UNEXPECTEDEND);
-
-               result = dns_rdata_tostruct(&rdata, &sig, msg->mctx);
-               if (result != ISC_R_SUCCESS)
-                       return (result);
-
-               dns_rdataset_init(&keyset);
-               if (view == NULL)
-                       return (DNS_R_KEYUNAUTHORIZED);
-               result = dns_view_simplefind(view, &sig.signer,
-                                            dns_rdatatype_key /* SIG(0) */,
-                                            0, 0, false, &keyset, NULL);
-
-               if (result != ISC_R_SUCCESS) {
-                       /* XXXBEW Should possibly create a fetch here */
-                       result = DNS_R_KEYUNAUTHORIZED;
-                       goto freesig;
-               } else if (keyset.trust < dns_trust_secure) {
-                       /* XXXBEW Should call a validator here */
-                       result = DNS_R_KEYUNAUTHORIZED;
-                       goto freesig;
-               }
-               result = dns_rdataset_first(&keyset);
-               INSIST(result == ISC_R_SUCCESS);
-               for (;
-                    result == ISC_R_SUCCESS;
-                    result = dns_rdataset_next(&keyset))
-               {
-                       dst_key_t *key = NULL;
-
-                       dns_rdata_reset(&rdata);
-                       dns_rdataset_current(&keyset, &rdata);
-                       isc_buffer_init(&b, rdata.data, rdata.length);
-                       isc_buffer_add(&b, rdata.length);
-
-                       result = dst_key_fromdns(&sig.signer, rdata.rdclass,
-                                                &b, view->mctx, &key);
-                       if (result != ISC_R_SUCCESS)
-                               continue;
-                       if (dst_key_alg(key) != sig.algorithm ||
-                           dst_key_id(key) != sig.keyid ||
-                           !(dst_key_proto(key) == DNS_KEYPROTO_DNSSEC ||
-                             dst_key_proto(key) == DNS_KEYPROTO_ANY))
-                       {
-                               dst_key_free(&key);
-                               continue;
-                       }
-                       result = dns_dnssec_verifymessage(&msgb, msg, key);
-                       dst_key_free(&key);
-                       if (result == ISC_R_SUCCESS)
-                               break;
-               }
-               if (result == ISC_R_NOMORE)
-                       result = DNS_R_KEYUNAUTHORIZED;
-
- freesig:
-               if (dns_rdataset_isassociated(&keyset))
-                       dns_rdataset_disassociate(&keyset);
-               dns_rdata_freestruct(&sig);
-               return (result);
+               return (dns_tsig_verify(&msgb, msg, NULL, NULL));
        }
 }