Maradns · Maradns · CVE-2023-31137
**Name of the Vulnerable Software and Affected Versions**
MaraDNS versions 3.5.0024 and prior
**Description**
MaraDNS is open-source software that implements the Domain Name System (DNS). A remotely exploitable integer underflow vulnerability in the DNS packet decompression function allows an attacker to cause a Denial of Service by triggering an abnormal program termination. The vulnerability exists in the `decomp get rddata` function within the `Decompress.c` file. When handling a DNS packet with an Answer RR of qtype 16 (TXT record) and any qclass, if the `rdlength` is smaller than `rdata`, the result is a negative number `len = rdlength - total;`. This value is then passed to the `decomp append bytes` function without proper validation, causing the program to attempt to allocate a massive chunk of memory that is impossible to allocate. Consequently, the program exits with an error code of 64, causing a Denial of Service.
**Recommendations**
To resolve the issue, update to version 3.5.0036 or later, which incorporates the fix for this vulnerability by patching `Decompress.c:887` with a check for `if(len <= 0)`. As a temporary workaround, consider restricting access to the `decomp get rddata` function within the `Decompress.c` file to minimize the risk of exploitation.