CVE-2023-31137
📋 TL;DR
A remotely exploitable integer underflow vulnerability in MaraDNS allows attackers to cause Denial of Service by sending specially crafted DNS packets. When processing TXT records with malformed rdlength values, the program attempts to allocate impossible amounts of memory and crashes. This affects MaraDNS servers running vulnerable versions.
💻 Affected Systems
- MaraDNS
📦 What is this software?
Fedora by Fedoraproject
Fedora by Fedoraproject
Maradns by Maradns
Maradns by Maradns
⚠️ Risk & Real-World Impact
Worst Case
Complete service disruption of DNS resolution, potentially affecting all services dependent on DNS lookups from the vulnerable server.
Likely Case
Intermittent DNS service outages when attackers send malicious packets, causing service disruptions.
If Mitigated
Minimal impact with proper network segmentation and monitoring to detect and block malicious DNS traffic.
🎯 Exploit Status
The vulnerability requires sending a specially crafted DNS packet, which is relatively simple to create. No authentication is required as DNS servers accept queries from any source.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Version 3.5.0036 and later
Vendor Advisory: https://github.com/samboy/MaraDNS/security/advisories/GHSA-58m7-826v-9c3c
Restart Required: Yes
Instructions:
1. Download MaraDNS version 3.5.0036 or later from the official repository. 2. Stop the MaraDNS service. 3. Replace the vulnerable binary with the patched version. 4. Restart the MaraDNS service.
🔧 Temporary Workarounds
Network filtering for malicious DNS packets
allUse network firewalls or intrusion prevention systems to block DNS packets containing TXT records with suspicious rdlength values.
Disable TXT record processing
linuxConfigure MaraDNS to reject or ignore TXT record queries if not required for your environment.
# Modify MaraDNS configuration to filter TXT record queries
🧯 If You Can't Patch
- Implement strict network segmentation to limit access to DNS servers only from trusted sources.
- Deploy rate limiting on DNS queries to make DoS attacks more difficult and monitor for abnormal traffic patterns.
🔍 How to Verify
Check if Vulnerable:
Check the MaraDNS version: if it's 3.5.0024 or earlier, it's vulnerable. Review system logs for error code 64 exits.
Check Version:
maradns --version
Verify Fix Applied:
Verify the installed version is 3.5.0036 or later. Test with crafted DNS packets containing TXT records to ensure the service remains stable.
📡 Detection & Monitoring
Log Indicators:
- Program exits with error code 64
- Memory allocation failure messages in system logs
- Abnormal termination of MaraDNS process
Network Indicators:
- Unusual volume of DNS queries with TXT records
- DNS packets with malformed rdlength fields
SIEM Query:
source="mara.log" AND ("error 64" OR "abnormal termination" OR "memory allocation failed")
🔗 References
- https://github.com/samboy/MaraDNS/blob/08b21ea20d80cedcb74aa8f14979ec7c61846663/dns/Decompress.c#L886
- https://github.com/samboy/MaraDNS/commit/bab062bde40b2ae8a91eecd522e84d8b993bab58
- https://github.com/samboy/MaraDNS/security/advisories/GHSA-58m7-826v-9c3c
- https://lists.debian.org/debian-lts-announce/2023/06/msg00019.html
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/3VSMLJX25MXGQ6A7UPOGK7VPUVDESPHL/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/NB7LDZM5AGWC5BHHQHW6CP5OFNBBKFOQ/
- https://www.debian.org/security/2023/dsa-5441
- https://github.com/samboy/MaraDNS/blob/08b21ea20d80cedcb74aa8f14979ec7c61846663/dns/Decompress.c#L886
- https://github.com/samboy/MaraDNS/commit/bab062bde40b2ae8a91eecd522e84d8b993bab58
- https://github.com/samboy/MaraDNS/security/advisories/GHSA-58m7-826v-9c3c
- https://lists.debian.org/debian-lts-announce/2023/06/msg00019.html
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/3VSMLJX25MXGQ6A7UPOGK7VPUVDESPHL/
- https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/NB7LDZM5AGWC5BHHQHW6CP5OFNBBKFOQ/
- https://www.debian.org/security/2023/dsa-5441