gnrc_rpl: missing bounds checks in _parse_options #16085
Labels
Area: network
Area: Networking
Type: bug
The issue reports a bug / The PR fixes a bug (including spelling errors)
Description
The implementation of
_parse_options
ingnrc_rpl
has a problem very similar to the one described in #16062: It casts packed structs without performing prior boundary checks. I think the loop code is in fact more or less a copy of the one ingnrc_rpl_validation_options
, thus a fix very similar to #16081 will be needed for it too.Consider for example the following code:
RIOT/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c
Line 619 in 896e44c
In this case it might be the case that
len < sizeof(gnrc_rpl_opt_target_t)
, however this case is not covered by the implementation currently. There are also other casts to packed structs in this function which have the same issue.Steps to reproduce the issue
Use
examples/gnrc_networking
, activategnrc_pktbuf_malloc
and setCONFIG_GNRC_RPL_DEFAULT_NETIF
to your netif (check withifconfig
in the shell provided bygnrc_networking
) mine is6
:I was also a bit too lazy to figure out how I can add an ULA to a
BOARD=native
network interface, to work around that I just made sure thatgnrc_rpl
uses the first available networking interface for DODAGs with the following patch (if you know how to configure a non-local address on aBOARD=native
network interface please let me know):Note: If you don't want to apply this patch, it should also be possible to reproduce this issue by adding a non-local IPv6 address to your network interface and passing that address to the
rpl root
command below.Compile and run the application using:
In the RIOT term initialize the RPL root instance with the following command (the address passed to
rpl root
doesn't matter due to the patch from above):Afterwards run
socat
as:Expected results
The application shouldn't crash.
Actual results
CC: @cgundogan
The text was updated successfully, but these errors were encountered: