HIGH 7.4

CVE-2026-10646: Zephyr DNS Use-After-Return Vulnerability in getaddrinfo()

Zephyr's DNS socket implementation contains a use-after-return vulnerability in its getaddrinfo() function. When a DNS query times out and is retried, the code fails to properly clean up the previous query before starting a new one. This leaves a stale callback pointing to an expired stack memory location. When a DNS response arrives—whether from a legitimate delayed resolver or spoofed by an attacker on the network—it triggers the dangling callback, which then writes data into memory that has already been reused by other functions. An attacker can exploit this via crafted or replayed DNS responses to corrupt memory, crash the system, or potentially execute code. This affects Zephyr versions 4.0.0 through 4.4.0.

Source data · NVD / CISA · public domain

CVSS
3.1 · 7.4 HIGH · CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:H
Weaknesses (CWE)
CWE-416
Affected products
1 configuration(s)
Published / Modified
2026-06-28 / 2026-07-14

NVD description (verbatim)

Zephyr's BSD-sockets getaddrinfo() implementation (subsys/net/lib/sockets/getaddrinfo.c) passes a pointer to a stack-allocated state object (struct getaddrinfo_state ai_state) as the user_data of an asynchronous DNS resolver query. The socket layer waits on a semaphore with a timeout deliberately set slightly longer than the resolver's own per-query timeout. When that semaphore wait nonetheless times out (-EAGAIN) - which can occur when the resolver's timeout work is delayed by workqueue contention, or in the documented multi-retry configuration where CONFIG_NET_SOCKETS_DNS_TIMEOUT exceeds CONFIG_NET_SOCKETS_DNS_BACKOFF_INTERVAL - the pre-fix code retries the query (goto again) without cancelling the previous one and without resetting the semaphore. The previous query slot remains active in the resolver with its callback and the stack pointer as user_data, and ai_state->dns_id is overwritten so the stale query can no longer be cancelled. A subsequent DNS response delivered over UDP and matched by its 16-bit transaction id (in dispatcher_cb()/dns_read()), or the resolver's own delayed query-timeout work, then invokes dns_resolve_cb() against the now out-of-scope stack frame, writing through the stale pointer (state->status, state->idx, state->ai_arr[], and k_sem_give()). Because the triggering response is network-delivered and its 16-bit id is spoofable/replayable by an on- or off-path attacker, this is a network-influenceable use-after-return that can corrupt reused stack memory, leading to crashes/denial of service or memory corruption. The fix cancels the timed-out query by name and type before retrying and resets the local semaphore, eliminating the stale callback path. Affected: Zephyr v4.0.0 through v4.4.0.

2 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

The vulnerability exists in subsys/net/lib/sockets/getaddrinfo.c where the socket layer waits on a semaphore with a timeout slightly longer than the DNS resolver's per-query timeout. When the semaphore wait times out (returning -EAGAIN)—which can occur due to workqueue delays or multi-retry configurations where CONFIG_NET_SOCKETS_DNS_TIMEOUT exceeds CONFIG_NET_SOCKETS_DNS_BACKOFF_INTERVAL—the code retries the DNS query without cancelling the in-flight query or resetting the semaphore. The struct getaddrinfo_state (ai_state) pointer, passed as user_data to the async resolver, remains registered as a callback with a stack address. The ai_state->dns_id is overwritten, making the stale query uncancellable. When a DNS response arrives and matches the 16-bit transaction ID (via dispatcher_cb() or dns_read()), or when the resolver's delayed timeout work fires, dns_resolve_cb() executes against the now-invalid stack frame, writing to state->status, state->idx, state->ai_arr[], and calling k_sem_give() through a use-after-return pointer. The 16-bit transaction ID is spoofable and replayable by network-positioned attackers. The fix cancels the timed-out query by name and type before retry and resets the semaphore to eliminate the stale callback path.

Business impact

This vulnerability enables network-based denial of service and potential memory corruption on Zephyr-based IoT and embedded devices. An attacker with network access (on-path or off-path via ID spoofing) can trigger crashes by sending crafted or replayed DNS responses, disrupting device availability. In memory-constrained embedded environments, the corruption could enable escalation to code execution or system compromise. For organizations deploying Zephyr in critical IoT applications, industrial control, or safety-critical systems, this represents a significant availability and integrity risk that requires prompt remediation.

Affected systems

Zephyr RTOS versions 4.0.0 through 4.4.0 are affected. Specifically, the getaddrinfo() implementation in the BSD sockets subsystem is vulnerable when DNS resolution with timeouts and retries is active. Systems using Zephyr's socket-based DNS resolution in multi-threaded or workqueue-contended environments are at higher risk. Devices relying on DNS for any network service (HTTP, MQTT, CoAP, etc.) are exposed if they cannot isolate DNS queries or rely on external DNS resolvers.

Exploitability

Exploitability is moderate to high. An attacker needs network access to the target device (or the ability to inject traffic on its network path), but does not require elevated privileges, user interaction, or special configuration beyond basic DNS usage. The 16-bit transaction ID is small enough that an attacker can brute-force or replay captured IDs, especially in high-traffic scenarios. The attack is reliable if the attacker can observe or predict DNS query patterns. Denial of service via sustained DNS response injection is straightforward and requires minimal resources. Memory corruption exploitation is harder but not implausible on systems with predictable stack layouts.

Remediation

Users must upgrade to a patched version of Zephyr that includes the fix to getaddrinfo.c (verify exact version against the official Zephyr security advisory). The patch cancels timed-out queries by name and type before retry and resets the semaphore. As an interim mitigation, organizations can reduce DNS timeout and retry configurations to minimize the window, or route DNS through a trusted, rate-limited proxy that filters malformed responses. However, these are workarounds; upgrading is the definitive fix.

Patch guidance

Monitor the Zephyr project's official security advisories for release of patched versions addressing CVE-2026-10646. Once available, patch versions should be integrated into your build and deployed across all affected Zephyr-based devices. Test patches in a non-production environment, particularly in high-workqueue-contention scenarios, to confirm stability. If devices cannot be patched immediately, implement network segmentation and egress filtering to restrict DNS traffic to trusted, monitored resolvers.

Detection guidance

Look for repeated DNS timeouts and retries in system logs, followed by unexpected crashes or memory corruption errors (hard faults, segmentation faults, or heap corruption warnings). Monitor for anomalies in DNS response patterns (duplicate transaction IDs, out-of-sequence responses). Implement network-level monitoring for DNS traffic to the affected devices; watch for reply flooding or replay of previously observed query IDs. Enable Zephyr kernel logging at DEBUG level for DNS and socket subsystems to capture evidence of stale callbacks or semaphore anomalies. Memory corruption detection tools (ASAN, stack canaries) may catch the write-through-stale-pointer, but typically only in post-mortem analysis after a crash.

Why prioritize this

With a CVSS score of 7.4 (HIGH) and network-exploitability, this warrants high-priority patching. The vulnerability does not require user interaction or special privileges, and an attacker can trigger it remotely by injecting spoofed DNS responses. While memory corruption exploitation is not trivial, denial of service is immediate and impactful. Zephyr's deployment in IoT and critical embedded systems amplifies the business risk. Organizations using affected Zephyr versions should prioritize patch assessment and deployment within their standard critical vulnerability response window (typically 1–2 weeks).

Risk score, explained

The CVSS 3.1 score of 7.4 reflects HIGH severity: a network vector (AV:N), attack complexity of high (AC:H—requires timing/workqueue conditions or multi-retry configuration to trigger), no privileges or user interaction required, and impacts both integrity (I:H—memory corruption) and availability (A:H—crash/DoS). Confidentiality is not impacted (C:N). The AC:H rating acknowledges that the vulnerability requires specific conditions (workqueue delay or multi-retry setup) to manifest, but these are common in real Zephyr deployments. The network vector and spoofability of the 16-bit DNS ID elevate exploitability despite AC:H.

Frequently asked questions

Does this vulnerability require the attacker to be on the same network?

No. While an on-path attacker has an easier time injecting DNS responses, an off-path attacker can spoof replies because the 16-bit DNS transaction ID is small (65,536 possible values) and can be brute-forced or replayed if the attacker has captured previous responses. The vulnerability is network-influenceable, meaning a remote attacker with the ability to reach the target device can exploit it.

What versions of Zephyr are safe?

Versions prior to 4.0.0 and patched versions after 4.4.0 are safe (consult the official Zephyr security advisory for the exact patched version number). Versions 4.0.0 through 4.4.0 inclusive are vulnerable. Verify the patch version against the vendor advisory before deploying.

Can we work around this without patching?

Partial mitigations exist: reduce DNS_TIMEOUT and DNS_BACKOFF_INTERVAL to shrink the retry window, or route DNS through a proxy that validates and rate-limits responses. However, these are workarounds. The definitive fix is to upgrade to a patched version.

What happens when the vulnerability is exploited?

The system experiences memory corruption when a DNS response overwrites reused stack memory. This typically causes a crash (denial of service), but could also silently corrupt in-flight data structures, leading to subtle logic errors. In edge cases with predictable stack layout, the corruption could be leveraged for code execution, though that is not the common outcome.

This analysis is provided for informational and defensive purposes. The vulnerability details and affected versions are sourced from the CVE record; consult the official Zephyr security advisory and vendor patch notes for definitive remediation steps and patch version numbers. SEC.co makes no warranty regarding the completeness or accuracy of this summary and assumes no liability for decisions made in reliance on it. Always test patches in a non-production environment before deployment. Exploit development, weaponization, and offensive use of this information are prohibited and may violate law. Source: NVD (public-domain), retrieved 2026-08-06. Analysis generated by SEC.co (claude-haiku-4-5).