CVE-2026-102963 in Zephyr
Summary
by MITRE • 11/27/2026
dns_resolve_cancel_with_name() in subsys/net/lib/dns/resolve.c looks up the pending query to cancel by DNS id plus a hash of the name the caller originally asked for. When a reply contains only a CNAME, the resolver sends a new query for the alias and overwrites the slot's query_hash with the hash of the alias name. After one or more CNAME hops, cancelling by the original name silently fails with -ENOENT and the query stays pending.
zsock_getaddrinfo() (exec_query() in subsys/net/lib/sockets/getaddrinfo.c) passes a pointer to its stack-local ai_state as the resolver callback context. When its semaphore wait times out, it calls dns_cancel_addr_info_with_name(), ignores the result, and returns. The CNAME re-query restarts the resolver timer, so a CNAME-only response that arrives more than about 100 ms after the query lets the getaddrinfo() wait expire first. The cancel then fails and getaddrinfo() returns. An attacker who can supply DNS responses can trigger this reliably: a malicious or compromised DNS server, an on-path attacker, or any host on the link for mDNS/LLMNR lookups. The device only has to resolve a name with getaddrinfo().
When the orphaned query later times out, dns_resolve_cb() writes the status and calls k_sem_give() on the dead stack frame. If the attacker answers the alias query instead, the callback copies attacker-supplied address data through a stale ai_arr pointer read from the reused stack. The result is a kernel fault (denial of service) or memory corruption in the calling thread's stack and whatever memory the stale pointer references.
If you want to get best quality of vulnerability data, you may have to visit VulDB.
Analysis
by VulDB Data Team • 11/27/2026
The vulnerability identified involves a critical race condition and use-after-free flaw within the DNS resolution subsystem, specifically affecting functions dns_resolve_cancel_with_name() and zsock_getaddrinfo(). The core technical issue stems from how pending DNS queries are tracked and cancelled when dealing with Canonical Name (CNAME) records. When a resolver initiates a lookup for a domain name, it stores metadata including a hash of the queried name in a specific slot to facilitate future cancellation requests. However, if the initial DNS response contains only a CNAME record pointing to an alias, the resolver automatically issues a new query for that alias and updates the slot's stored query_hash with the hash of the alias rather than retaining the original name's hash. This design decision creates a mismatch between how queries are initiated and how they can be cancelled by application-layer code expecting to cancel based on the originally requested domain name.
The operational impact is triggered when an application, such as one using zsock_getaddrinfo(), attempts to resolve a hostname with a timeout mechanism. The getaddrinfo implementation passes a pointer to its own stack-local state structure as the context for resolver callbacks and waits on a semaphore for resolution completion. If the DNS response includes CNAME records that cause additional lookups, these subsequent queries restart the internal resolver timers. Consequently, if the final answer arrives after approximately one hundred milliseconds, the application's wait timeout expires before the resolution completes. At this point, getaddrinfo calls dns_cancel_addr_info_with_name() to abort the pending operation. Because of the aforementioned hash mismatch caused by CNAME handling, the cancellation request fails silently with an error code indicating no matching entry was found (-ENOENT). The query remains active in the background despite the application believing it has been cancelled and proceeding to return control to the caller.
This scenario leads directly to a severe memory safety violation known as use-after-free or stack corruption. Since the original getaddrinfo function returns, its local variables, including the ai_state structure containing pointers to result arrays (ai_arr), are popped from the call stack and become invalid. However, the orphaned DNS query continues to run in the background. When this lingering query eventually times out or completes, it invokes a callback function dns_resolve_cb(). This callback attempts to write the resolution status and signal completion by calling k_sem_give() on the semaphore associated with the now-deallocated stack frame of the getaddrinfo caller. Accessing memory belonging to a freed stack frame results in undefined behavior, typically manifesting as a kernel fault or denial of service due to invalid pointer dereferences.
The severity escalates significantly if an attacker can influence the DNS response content. If a malicious actor controls the DNS server, operates on-path within the network segment, or exploits vulnerabilities in link-local multicast protocols like mDNS or LLMNR, they can craft responses that force CNAME redirections and manipulate timing to ensure the race condition occurs reliably. Furthermore, if the attacker provides an alias query response while the orphaned callback is executing, the resolver may copy attacker-supplied address data through a stale ai_arr pointer read from the reused stack memory. This allows for arbitrary write primitives or heap/stack corruption in the context of the calling thread, potentially leading to remote code execution depending on the specific memory layout and available exploitation techniques.
From a classification perspective, this vulnerability aligns with CWE-416 Use After Free, as it involves accessing memory after it has been made unavailable for use by deallocating or reusing that block in the stack context. It also relates to CWE-362 Concurrent Execution Using Shared Resource with Improper Synchronization due to the race condition between the application timeout and the asynchronous DNS callback execution. In terms of attack vectors, this falls under ATT&CK technique T1498 Network Denial of Service if exploited for denial of service via kernel faults, or potentially privilege escalation paths if memory corruption is leveraged effectively. The vulnerability highlights risks associated with asynchronous API designs where cancellation semantics do not strictly guarantee immediate termination of underlying background tasks, particularly when those tasks involve state updates that invalidate previous lookup identifiers.
Mitigation strategies must address both the race condition and the CNAME handling logic. First, the resolver should ensure that cancelling a query by its original name remains valid even after intermediate CNAME lookups have occurred, perhaps by maintaining a list of all associated hashes or preventing hash overwrites until the final resolution is complete. Second, strict synchronization mechanisms must be implemented to prevent callbacks from executing on stack frames that are no longer active; this could involve reference counting for resolver contexts or ensuring that cancellation requests properly invalidate pending callbacks before returning control to the application. Additionally, input validation and timeout handling in getaddrinfo should account for asynchronous cleanup delays to avoid assuming immediate resource release upon function return. Updating the DNS resolution library to enforce strict lifecycle management of query states will prevent orphaned queries from accessing stale memory references.