[riot-notifications] [RIOT-OS/RIOT] Memory read beyond input buffer boundaries in nanocoap packet parser (#14074)

Maciej Jurczak notifications at github.com
Wed May 13 23:47:52 CEST 2020

#### Description

The current packet parsing pointer is incremented by the token length provided in the packet header without checking if the resulting pointer is still in the valid input buffer boundaries:

Additionaly, the coap_get_token_len() function allows for reserved values (>8) up to 15 to be returned without indicating an invalid packet. 

The incremented pkt_pos pointer is further processed by the options parsing loop. If the pointer has skipped over the input buffer end, the loop will be entered and an invalid address read access may be made due to incorrect loop condition:

#### Steps to reproduce the issue
Provide an input packet with token length longer than the following packet length.

#### Expected results
An error code returned by the parsing function if a malformed packet is encountered. No access to memory areas out of the input buffer boundaries should be made.

return -EBADMSG;

#### Actual results
Read of memory outside the input boundaries. The parser continues processing beyond the provided input buffer.
Depending on memory allocation method and memory protection means it may result in crash or data processing beyond the input packet buffer.

#### Versions
master: 5ef4b1843af6749bf8f40b5a37dba9f793474a73
tag: 2020.04

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200513/bd2cbe93/attachment.htm>

More information about the notifications mailing list