Impact
It is possible to cause a buffer overflow when copying an IPv6 address prefix in the RPL-Classic implementation in Contiki-NG. In order to trigger the vulnerability, the Contiki-NG system must have joined an RPL DODAG. After that, an attacker can send a DAO packet with a Target option that contains a prefix length larger than 128 bits. The code fragment below shows the vulnerability, which resides in the module os/net/routing/rpl-classic/rpl-icmp6.c:
switch(subopt_type) {
case RPL_OPTION_TARGET:
prefixlen = buffer[i + 3];
memset(&prefix, 0, sizeof(prefix));
memcpy(&prefix, buffer + i + 4, (prefixlen + 7) / CHAR_BIT);
break;
Here, the prefixlen variable is taken without validation from the packet supplied by the potential attacker. Additionally, the memory copy does not verify that there are enough bytes available in the packet to copy (prefixlen + 7) / CHAR_BIT
bytes, which can thus trigger a read out of bounds as well.
Patches
The problem was fixed after the release of Contiki-NG 4.7. Before the next version is released, users can apply the workaround below.
Workarounds
Users can apply the patch in Contiki-NG PR #1615.
For more information
If you have any questions or comments about this advisory:
Impact
It is possible to cause a buffer overflow when copying an IPv6 address prefix in the RPL-Classic implementation in Contiki-NG. In order to trigger the vulnerability, the Contiki-NG system must have joined an RPL DODAG. After that, an attacker can send a DAO packet with a Target option that contains a prefix length larger than 128 bits. The code fragment below shows the vulnerability, which resides in the module os/net/routing/rpl-classic/rpl-icmp6.c:
Here, the prefixlen variable is taken without validation from the packet supplied by the potential attacker. Additionally, the memory copy does not verify that there are enough bytes available in the packet to copy
(prefixlen + 7) / CHAR_BIT
bytes, which can thus trigger a read out of bounds as well.Patches
The problem was fixed after the release of Contiki-NG 4.7. Before the next version is released, users can apply the workaround below.
Workarounds
Users can apply the patch in Contiki-NG PR #1615.
For more information
If you have any questions or comments about this advisory: