Sceawere
Vulnerability Detail
CVE-2026-14368UPDATED Verified Sceawere Triage Sources: NVD / CISA KEV
LwM2M JSON Buffer Overflow
Vulnerability Metadata
- Severity
- Medium
- Score / CVSS
- 5.4
- Creation Date
- 13h ago
- Vendor
- zephyrproject
- Product
- zephyr
- Attack Type
- bounds
- Vector String
- CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:L/A:L
- Attack Complexity
- LOW
Narrative and Response
Description
The LwM2M JSON content formatter's get_string() in subsys/net/lib/lwm2m/lwm2m_rw_json.c copies a parsed JSON string into a caller-supplied buffer and NUL-terminates it. The length guard used if (string_length > buflen), which accepts a string whose length is exactly buflen. After memcpy() fills the whole buffer, buf[string_length] = '\0' then writes one byte past the end of the buffer (CWE-787). The string value and its length are taken directly from the incoming CoAP payload during a LwM2M WRITE: do_write_op_json() parses the payload obtained from coap_packet_get_payload(), and get_string() is invoked from lwm2m_write_handler() (engine_get_string() in subsys/net/lib/lwm2m/lwm2m_message_handling.c) for a LWM2M_RES_TYPE_STRING resource. The destination buf/buflen is either the resource instance's fixed data buffer (res_inst->data_ptr/max_data_len) or the engine validation buffer (msg->ctx->validate_buf). A LwM2M server (the client's DTLS peer) can therefore write a string resource with a value whose length equals the target buffer size and force a one-byte overflow. The overflow is a single out-of-bounds write of the constant byte 0x00 immediately past the resource or validation buffer, corrupting the adjacent byte in memory. It is not an information leak and the written value is fixed, so it is not a direct code-execution primitive, but it can corrupt adjacent state (an adjacent resource value, a length/flag field, or a struct field) and cause data corruption or a crash. Triggering the write is deterministic; the resulting impact depends on memory layout. The fix changes the guard to string_length >= buflen, rejecting the exact-length case and aligning the JSON formatter with the other content formatters (lwm2m_rw_plain_text.c, lwm2m_rw_oma_tlv.c, lwm2m_rw_senml_json.c, lwm2m_rw_cbor.c, lwm2m_rw_senml_cbor.c), which already used the correct boundary check.
Executive Summary
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Technical Details
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Mitigations
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
References
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Additional Metadata
{
"score": "5.4",
"pubDate": "2026-08-31T19:16:45.887Z",
"pubdate": "2026-08-31T19:16:45.887Z",
"executiveSummary": "A heap-based or stack-based out-of-bounds write vulnerability (CWE-787) exists in the LwM2M JSON content formatter within the Zephyr RTOS networking subsystem. The vulnerability stems from an incorrect bounds check during the string parsing of LwM2M WRITE operations.\nThe flaw allows a remote DTLS peer (acting as an LwM2M server) to trigger a single-byte, out-of-bounds null-byte write when processing maliciously crafted CoAP payloads containing string resources. Although the exploit does not directly provide code execution, it enables deterministic corruption of memory adjacent to the target buffer.\nPotential impacts include memory corruption, service crashes (Denial of Service), or the manipulation of adjacent control structures, lengths, or resource flags. Successful exploitation requires an LwM2M WRITE operation from a connected peer. This vulnerability affects systems utilizing the Zephyr LwM2M engine and underscores the necessity for rigorous bounds checking in input parsing routines.",
"technicalDetails": "The vulnerability resides in the get_string() function within subsys/net/lib/lwm2m/lwm2m_rw_json.c. The root cause is an off-by-one error in the validation logic applied to incoming CoAP payload data. When the LwM2M engine processes a LWM2M_RES_TYPE_STRING resource, it attempts to copy the incoming string into a fixed-size buffer, either res_inst->data_ptr or msg->ctx->validate_buf.\nThe implementation uses the conditional check if (string_length > buflen) to determine if a string fits within the destination buffer. Because this condition permits scenarios where string_length equals buflen, the subsequent operation performs a memory copy that occupies the entirety of the buffer. Immediately following the memcpy() operation, the code executes buf[string_length] = '\\0' to enforce null-termination. If the string length is exactly equal to the buffer length, the index used for the null terminator is equal to the buffer size, effectively writing to the first memory address immediately following the allocated buffer space.\nThe attack flow follows these steps: 1) The attacker initiates an LwM2M WRITE request containing a string value of length N. 2) The LwM2M engine routes the payload to do_write_op_json(). 3) The function invokes get_string(), passing the incoming string and the target buffer size (N). 4) The insufficient boundary check fails to prevent the copy. 5) The buffer is filled with the string content. 6) The function attempts to null-terminate at index N, resulting in an out-of-bounds write at offset N+1.\nThis behavior is deterministic, as the attacker controls the length of the string provided in the CoAP payload. The impact depends entirely on the memory layout of the surrounding structures. If the buffer is adjacent to critical metadata, such as length fields, pointers, or function pointers, the null-byte overwrite could cause application instability, logic bypasses, or crashes. Because the written value is always a fixed 0x00 byte, the vulnerability is not an information leak but acts as a primitive for controlled corruption of adjacent state."
}