CVE-2026-104377 in Zephyr
Summary
by MITRE • 11/29/2026
The Zephyr TFTP client library (subsys/net/lib/tftp/tftp_client.c) reports server ERROR packets to the application through a TFTP_EVT_ERROR event whose evt.param.error.msg field is a bare char * pointing at client->tftp_buf + TFTP_HEADER_SIZE, with no length. RFC 1350 requires the ERROR message to be NUL-terminated, but tftp_get(), tftp_put() and send_data() never checked or enforced this before invoking the callback.
A TFTP server (or an on-path/spoofing attacker able to inject a UDP datagram from the server's address) can answer a client request with a full-size 516-byte ERROR datagram whose message has no terminator. The callback then receives a string that runs to the end of tftp_buf, which is the last member of the application-owned struct tftpc, so any string operation on it (for example the %s logging done by the in-tree sample and net tftp shell callbacks) reads past the end of the object until a stray zero byte is found. A 4-byte ERROR with no message similarly exposes stale, possibly unterminated buffer contents from the previous packet.
The impact is an out-of-bounds read of memory adjacent to the struct tftpc object in the context of the application callback. Depending on what the application does with the message, this can disclose adjacent memory (e.g. into logs or anything the application forwards) or fault if the read reaches unmapped or protected memory. No out-of-bounds write is possible. The fix NUL-terminates the message inside tftp_buf at the received length, clamped to the last byte of the buffer.
If you want to get best quality of vulnerability data, you may have to visit VulDB.
Analysis
by VulDB Data Team • 11/29/2026
The Zephyr real-time operating system contains a critical vulnerability within its Trivial File Transfer Protocol client library located in subsys/net/lib/tftp/tftp_client.c. This flaw stems from an improper handling of error responses received from TFTP servers, specifically regarding how the ERROR packet's message payload is processed before being passed to application-level callbacks. Under normal operation, when a TFTP server encounters an issue such as file not found or access violation, it sends back an ERROR packet containing a human-readable description of the problem. The Zephyr implementation extracts this message and passes it to the application via a TFTP_EVT_ERROR event structure. However, the code fails to validate that the incoming error message is properly terminated with a null character as mandated by RFC 1350, which defines the standard for the Trivial File Transfer Protocol. Instead of ensuring termination, the library simply points an evt.param.error.msg field directly at the buffer location within client->tftp_buf where the message begins, providing no length information and assuming valid string formatting that may not exist in maliciously crafted packets.
This lack of validation creates a significant out-of-bounds read vulnerability when interacting with untrusted or compromised network endpoints. An attacker who can inject UDP datagrams spoofing the server's address, or a misconfigured TFTP server itself, can send an ERROR packet containing a message that lacks a null terminator and extends to fill most of the 516-byte maximum datagram size allowed by RFC 1350. Because the receiving functions tftp_get(), tftp_put(), and send_data() do not enforce or check for this termination before invoking the callback, the application receives a pointer to data that continues beyond the intended message boundary. Since the tftp_buf is typically allocated as part of an application-owned struct tftpc object, reading past its end results in accessing memory adjacent to this structure on the stack or heap depending on allocation context. This behavior aligns with CWE-125 Out-of-bounds Read and represents a classic buffer over-read condition where the program reads data beyond the allocated boundary without proper bounds checking.
The operational impact of this vulnerability is primarily information disclosure and potential denial of service through application crashes. When the application processes the malformed error message, common practices such as logging via printf-style functions with %s specifiers will continue reading memory until a stray zero byte is encountered somewhere in adjacent memory regions. This can lead to sensitive data leakage if those adjacent bytes contain credentials, session tokens, or other private information stored nearby in memory structures. Alternatively, if the read operation encounters unmapped virtual memory pages or protected kernel space boundaries depending on the execution context, it will trigger a segmentation fault or general protection exception causing the application to crash abruptly. While there is no mechanism for arbitrary code execution via out-of-bounds write since only reads are performed during this callback invocation, the reliability and confidentiality guarantees of systems relying on Zephyr's networking stack are severely compromised by these memory safety violations.
From a threat modeling perspective using MITRE ATT&CK frameworks, this vulnerability facilitates reconnaissance activities where an attacker can probe internal network structures or extract sensitive data through side-channel effects caused by memory disclosure. It also enables denial-of-service attacks against embedded devices running Zephyr that depend on stable TFTP operations for firmware updates or configuration management. The attack vector is classified as Network-based with the requirement of being able to inject packets from a spoofed source address, which may be feasible in local network segments lacking proper ingress filtering or in scenarios where DNS rebinding or other IP spoofing techniques are employed. Mitigation strategies must focus on enforcing strict input validation at the protocol parsing layer rather than relying on application-level assumptions about data integrity.
The recommended remediation involves modifying the tftp_client.c implementation to explicitly NUL-terminate the error message string within the tftp_buf before passing it to any callback functions. This fix should clamp the termination character position to the last valid byte of the buffer to prevent writing beyond allocated limits while ensuring that all subsequent string operations operate on well-formed data regardless of what content was received from the network. Developers integrating Zephyr networking components should also implement defensive programming practices by validating pointer validity and length constraints before performing any string manipulations or logging operations on user-controlled input derived from protocol payloads. Regular security audits focusing on RFC compliance for legacy protocols like TFTP are essential to prevent similar issues in other subsystems that may share analogous parsing patterns without adequate boundary checks.