CVE-2020-35857 (published 2020-12-31T10:15Z)

An issue was discovered in the trust-dns-server crate before 0.18.1 for Rust. DNS MX and SRV null targets are mishandled, causing stack consumption.

Severity: MEDIUM
CVSS v2 base score: 5.0 (AV:N/AC:L/Au:N/C:N/I:N/A:P)
CVSS v3 base score: 7.5, HIGH (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H)

Weakness information:
cwe_id: CWE-400
cwe_name: Uncontrolled Resource Consumption
description: The product does not properly control the allocation and maintenance of a limited resource, thereby enabling an actor to influence the amount of resources consumed, eventually leading to the exhaustion of available resources.
extended_description: 
            Limited resources include memory, file system storage, database connection pool entries, and CPU. If an attacker can trigger the allocation of these limited resources, but the number or size of the resources is not controlled, then the attacker could cause a denial of service that consumes all available resources. This would prevent valid users from accessing the product, and it could potentially have an impact on the surrounding environment. For example, a memory exhaustion attack against an application could slow down the application as well as its host operating system.
            There are at least three distinct scenarios which can commonly lead to resource exhaustion:
               
                  Lack of throttling for the number of allocated resources
                  Losing all references to a resource before reaching the shutdown stage
                  Not closing/returning a resource after processing
               
            Resource exhaustion problems are often result due to an incorrect implementation of the following situations:
               
                  Error conditions and other exceptional circumstances.
                  Confusion over which part of the program is responsible for releasing the resource.
               
         
         

Fix information:
repo_url: https://github.com/bluejekyll/trust-dns
commit_details: repo_url: https://github.com/bluejekyll/trust-dns
author: Benjamin Fry
author_date: 2020-01-04 11:58:17-08:00
msg: reproduce error stack overflow from `.` as MX target

stop additional lookup on Root name
repository: repo_url: https://github.com/bluejekyll/trust-dns
repo_name: hickory-dns/hickory-dns
description: A Rust based DNS client, server, and resolver
repo_language: Rust
owner: bluejekyll
file_changes: filename: authority.rs
change_type: ModificationType.MODIFY
diff: @@ -92,6 +92,7 @@ impl FileAuthority {
             origin,
             records.len()
         );
+        debug!("zone: {:#?}", records);
 
         FileAuthority::new(origin, records, zone_type, allow_axfr)
     }

programming_language: Rust
filename: authority.rs
change_type: ModificationType.MODIFY
diff: @@ -227,7 +227,8 @@ impl InMemoryAuthority {
         and_rrsigs: bool,
         supported_algorithms: SupportedAlgorithms,
     ) -> Option<Arc<RecordSet>> {
-        let wildcard = if name.is_wildcard() {
+        // if this is a wildcard or a root, both should break continued lookups
+        let wildcard = if name.is_wildcard() || name.is_root() {
             return None;
         } else {
             name.clone().into_wildcard()

programming_language: Rust
filename: basic.rs
change_type: ModificationType.MODIFY
diff: @@ -146,6 +146,29 @@ pub fn test_mx<A: Authority<Lookup = AuthLookup>>(authority: A) {
     assert_eq!(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), *aaaa);
 }
 
+pub fn test_mx_to_null<A: Authority<Lookup = AuthLookup>>(authority: A) {
+    let query = Query::query(
+        Name::from_str("no-service.example.com.").unwrap(),
+        RecordType::MX,
+    );
+
+    let mut lookup =
+        block_on(authority.search(&query.into(), false, SupportedAlgorithms::new())).unwrap();
+
+    // In this case there should be no additional records
+    assert!(lookup.take_additionals().is_none());
+
+    let mx = lookup
+        .into_iter()
+        .next()
+        .expect("MX record not found in authority")
+        .rdata()
+        .as_mx()
+        .expect("Not an MX record");
+
+    assert_eq!(Name::from_str(".").unwrap(), *mx.exchange());
+}
+
 pub fn test_cname<A: Authority<Lookup = AuthLookup>>(authority: A) {
     let query = Query::query(
         Name::from_str("alias.example.com.").unwrap(),
@@ -565,6 +588,9 @@ macro_rules! define_basic_test {
         $(
             #[test]
             fn $f () {
+                // Useful for getting debug logs
+                // env_logger::init();
+
                 let authority = crate::$new("../../tests/test-data/named_test_configs/example.com.zone", module_path!(), stringify!($f));
                 crate::authority_battery::basic::$f(authority);
             }
@@ -583,6 +609,7 @@ macro_rules! basic_battery {
                     test_ns,
                     test_ns_lookup,
                     test_mx,
+                    test_mx_to_null,
                     test_cname,
                     test_cname_alias,
                     test_cname_chain,

programming_language: Rust
filename: example.com.zone
change_type: ModificationType.MODIFY
diff: @@ -27,3 +27,5 @@ aname-chain     ANAME   alias
 server          SRV     1 1 443 alias
 
 *.wildcard      CNAME   www
+
+no-service 86400 IN MX 0 .
\ No newline at end of file

programming_language: Markdown