From 541b5e5b71d6025cb250de7c0ade4d0d85c5b3b9 Mon Sep 17 00:00:00 2001 From: Erik van Luijk Date: Thu, 8 Apr 2021 18:02:22 +0200 Subject: [PATCH] Node reacting on invalid NS message Added validity check in lwIP stack ICMPv6 NDP implementation. According to RFC 4861 (chapter 7.1.1) a neighbor solicitation message which has its source IPv6 address set to the 'unspecified address' (0::0) and has the ICMPv6 option 'Source Link-Layer Address' set must be silently discarded. --- src/core/ipv6/nd6.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core/ipv6/nd6.c b/src/core/ipv6/nd6.c index d4673ca6..c8e301dc 100644 --- a/src/core/ipv6/nd6.c +++ b/src/core/ipv6/nd6.c @@ -472,7 +472,6 @@ nd6_input(struct pbuf *p, struct netif *inp) /* @todo RFC MUST: all included options have a length greater than zero */ /* @todo RFC MUST: if IP source is 'any', destination is solicited-node multicast address */ - /* @todo RFC MUST: if IP source is 'any', there is no source LL address option */ /* Check if there is a link-layer address provided. Only point to it if in this buffer. */ if (p->len >= (sizeof(struct ns_header) + 2)) { @@ -483,6 +482,15 @@ nd6_input(struct pbuf *p, struct netif *inp) } else { lladdr_opt = NULL; } + + /* RFC MUST: if IP source is 'any', there is no source LL address option */ + if (ip6_addr_isany(ip6_current_src_addr()) && lladdr_opt != NULL) { + /* Combined IP source address 'any' with source LL address option, drop frame. */ + pbuf_free(p); + ND6_STATS_INC(nd6.proterr); + ND6_STATS_INC(nd6.drop); + return; + } /* Check if the target address is configured on the receiving netif. */ accepted = 0; -- 2.30.1.windows.1