CVE-2026-104377: Out-of-bounds read via unterminated TFTP ERROR message in Zephyr TFTP client
The Zephyr TFTP client library (subsys/net/lib/tftp/tftpclient.c) reports server ERROR packets to the application through a TFTPEVTERROR event whose evt.param.error.msg field is a bare char pointing at client->tftpbuf + TFTPHEADERSIZE, with no length. RFC 1350 requires the ERROR message to be NUL-terminated, but tftpget(), tftpput() and senddata() 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 tftpbuf, 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 tftpbuf at the received length, clamped to the last byte of the buffer.
Affected Software
Event History
Frequently Asked Questions
Which applications are exposed to this issue?
Applications using the Zephyr TFTP client are exposed when their TFTP event callback handles TFTP_EVT_ERROR and treats evt.param.error.msg as a NUL-terminated string. In-tree sample and net TFTP shell callbacks that log the value with %s are identified as examples.
What does an attacker need to exploit it?
An attacker must be able to act as the TFTP server, or inject a UDP datagram that appears to come from the server address. They can respond to a client request with an ERROR packet whose message lacks a NUL terminator.
What can be done if an update cannot be applied immediately?
Do not use evt.param.error.msg with unbounded string operations, including %s logging, because the field has no associated length and may not be NUL-terminated. Review TFTP_EVT_ERROR callbacks for string handling of this field.
How can the vulnerable condition be triggered or recognized?
A full-size 516-byte ERROR datagram with no message terminator causes reads beyond the end of the application-owned tftpc object when the callback performs string processing. A 4-byte ERROR datagram with no message can instead expose stale, potentially unterminated contents from a prior packet.