Skip to content

Out-of-Bounds Write in nanoCoAP Handler

High
maribu published GHSA-qgj4-9jff-93cj Mar 11, 2026

Package

RIOT-OS (C/C++)

Affected versions

<= 2026.01

Patched versions

None

Description

Summary

Short summary of the problem. Make the impact and severity as clear as possible. For example: An unsafe deserialization vulnerability allows any unauthenticated user to execute arbitrary code on the server.

The default handler for the well_known_core resource coap_well_known_core_default_handler writes user-provided option data and other data into a fixed size buffer without validating the buffer is large enough to contain the response. This vulnerability allows an attacker to corrupt neighboring stack location, including security-sensitive addresses like the return address, leading to denial of service or arbitrary code execution.

Details

Give all details on the vulnerability. Pointing to the incriminated source code is very helpful for the maintainer.

Here is the execution trace that trigger the vulnerability:

  • In nanocoap.h:L2621, RIOT registers coap_well_known_core_default_handler as the handler to the path /.well-known/core
  • In sock.c:L1217, the nanocoap server is started with a fixed-size response buffer. By default, this buffer has only 112 bytes (default value of CONFIG_NANOCOAP_SERVER_BUF_SIZE).
  • An attacker sends a valid CoAP packet to the nanocoap server with the CoAP header and extended token length greater than 112 bytes.
  • The packet is received by the sock_udp_recv_buf_aux function and validated by the coap_parse_udp function. Specifically, this validation only ensures the received packet is valid but does not enforce any maximum size on the extended token or options in the packet. coap_handle_req is then called to process the packet, with the pointer and size of the fixed-size buffer passed as arguments.
  • coap_handle_req -> coap_tree_handler -> resource->handler -> coap_well_known_core_default_handler.
  • The coap_well_known_core_default_handler function calculates a pointer to the payload based on the length of the header and extended token length nanocoap.c:L1510 and does not validate the computed pointer is still within the bounds of the fixed size buffer.
  • Finally, in lines 1512 -- 1526 the handler goes on to write multiple bytes of data into the computed pointer, including options data from the received packet, without validating the bounds of the pointer.

PoC

Complete instructions, including specific configuration details, to reproduce the vulnerability.

Impact

What kind of vulnerability is it? Who is impacted?

This is an out-of-bound write vulnerability and will affect RIOT users who:

  • Use the nanocoap server implementation
  • Enable and expose the well-known/core resource to untrusted clients
  • Supports extended token length feature.

This vulnerability will allow an attacker to corrupt stack memory, overwrite sensitive data and addresses, and in the worst case (especially in embedded systems where memory protections are commonly absent), hijack the execution of the server.

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
High
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N

CVE ID

CVE-2026-27703

Weaknesses

Out-of-bounds Write

The product writes data past the end, or before the beginning, of the intended buffer. Learn more on MITRE.

Credits