Bug 224247 - [patch] RFC 6980 requires to drop fragmented IPv6 neighbour discovery
Summary: [patch] RFC 6980 requires to drop fragmented IPv6 neighbour discovery
Status: Closed Unable to Reproduce
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 11.1-STABLE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-net (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-12-11 14:55 UTC by Lutz Donnerhacke
Modified: 2018-05-29 16:02 UTC (History)
5 users (show)

See Also:


Attachments
Drop malicious packets as required by RFC 6980 (3.00 KB, patch)
2017-12-11 14:55 UTC, Lutz Donnerhacke
no flags Details | Diff
Drop malicious packets as required by RFC 6980 (2.88 KB, patch)
2017-12-12 12:13 UTC, Lutz Donnerhacke
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lutz Donnerhacke freebsd_committer freebsd_triage 2017-12-11 14:55:28 UTC
Created attachment 188720 [details]
Drop malicious packets as required by RFC 6980

RFC6980 says:
---8<---
   Nodes MUST silently ignore the following Neighbor Discovery and
   SEcure Neighbor Discovery messages if the packets carrying them
   include an IPv6 Fragmentation Header:

   o  Neighbor Solicitation

   o  Neighbor Advertisement

   o  Router Solicitation

   o  Router Advertisement

   o  Redirect

   o  Certification Path Solicitation

   Nodes SHOULD normally process the following messages when the packets
   carrying them include an IPv6 Fragmentation Header:

   o  Certification Path Advertisement

   SEND nodes SHOULD NOT employ keys that would result in fragmented CPA
   messages.
---8<---

A recent talk about this RFC showed, that FreeBSD fails in all respects to fulfill the minimal protection: http://www.denog.de/de/meetings/denog9/agenda.html#rfc6980

I hope, that the attached patch does fix the issue:
 - Fragment handling becomes a protocol specific mbuf-flag.
 - At detailed protocol level silent drop is implemented.
 - Certification Path messages are unsupported,
   so no sysctl to deal with the SHOULD is needed.
Comment 1 Lutz Donnerhacke freebsd_committer freebsd_triage 2017-12-11 15:07:12 UTC
More details from the original work:
https://insinuator.net/2017/06/testing-rfc-6980-implementations-of-freebsd/
Comment 2 Kristof Provost freebsd_committer freebsd_triage 2017-12-11 20:50:52 UTC
pf also does reassemble of IPv6 packets (see pf_reassemble6()), so that would also need a 'm->m_flags |= M_REASSEMBLED;'.
Comment 3 Lutz Donnerhacke freebsd_committer freebsd_triage 2017-12-12 12:13:32 UTC
Created attachment 188749 [details]
Drop malicious packets as required by RFC 6980
Comment 4 Lutz Donnerhacke freebsd_committer freebsd_triage 2017-12-12 12:16:21 UTC
Thank your for the pointer to functionality duplication in other modules.

I moved the flag-setting to the fragment header removal code (which is more appropriate anyway). This code is more likely to be shared by other modules (in the case of pf, it is used).

Furthermore the flag is renamed to be more self explanatory and the code was brushed up to match the existing coding style.

Did I miss anything else?
Comment 5 Andrey V. Elsukov freebsd_committer freebsd_triage 2017-12-13 11:32:05 UTC
(In reply to lutz from comment #4)
> Thank your for the pointer to functionality duplication in other modules.
> 
> I moved the flag-setting to the fragment header removal code (which is more
> appropriate anyway). This code is more likely to be shared by other modules
> (in the case of pf, it is used).
> 
> Furthermore the flag is renamed to be more self explanatory and the code was
> brushed up to match the existing coding style.
> 
> Did I miss anything else?

This looks good to me.
Comment 6 commit-hook freebsd_committer freebsd_triage 2017-12-15 12:38:13 UTC
A commit references this bug:

Author: ae
Date: Fri Dec 15 12:37:32 UTC 2017
New revision: 326876
URL: https://svnweb.freebsd.org/changeset/base/326876

Log:
  Follow the RFC6980 and silently ignore following IPv6 NDP messages
  that had the IPv6 fragmentation header:
   o  Neighbor Solicitation
   o  Neighbor Advertisement
   o  Router Solicitation
   o  Router Advertisement
   o  Redirect

  Introduce M_FRAGMENTED mbuf flag, and set it after IPv6 fragment reassembly
  is completed. Then check the presence of this flag in correspondig ND6
  handling routines.

  PR:		224247
  MFC after:	2 weeks

Changes:
  head/sys/netinet6/frag6.c
  head/sys/netinet6/icmp6.c
  head/sys/netinet6/in6.h
  head/sys/netinet6/nd6_nbr.c
  head/sys/netinet6/nd6_rtr.c
Comment 7 commit-hook freebsd_committer freebsd_triage 2017-12-29 10:47:54 UTC
A commit references this bug:

Author: ae
Date: Fri Dec 29 10:47:25 UTC 2017
New revision: 327337
URL: https://svnweb.freebsd.org/changeset/base/327337

Log:
  MFC r326876:
    Follow the RFC6980 and silently ignore following IPv6 NDP messages
    that had the IPv6 fragmentation header:
     o  Neighbor Solicitation
     o  Neighbor Advertisement
     o  Router Solicitation
     o  Router Advertisement
     o  Redirect

    Introduce M_FRAGMENTED mbuf flag, and set it after IPv6 fragment reassembly
    is completed. Then check the presence of this flag in correspondig ND6
    handling routines.

    PR:		224247

Changes:
_U  stable/11/
  stable/11/sys/netinet6/frag6.c
  stable/11/sys/netinet6/icmp6.c
  stable/11/sys/netinet6/in6.h
  stable/11/sys/netinet6/nd6_nbr.c
  stable/11/sys/netinet6/nd6_rtr.c
Comment 8 Lutz Donnerhacke freebsd_committer freebsd_triage 2018-01-28 17:08:19 UTC
Should the state of this ticket modified to "assigned", "patched", or even "fixed/closed"?
Comment 9 Nick Hilliard 2018-05-15 14:28:19 UTC
oops, looks like there are still issues.  see pages 31-33 of jacky hammer's preso:

https://ripe76.ripe.net/wp-content/uploads/presentations/67-RIPE76_JHammer_RFC6980.pdf
Comment 10 Lutz Donnerhacke freebsd_committer freebsd_triage 2018-05-15 15:32:34 UTC
I just relayed a question to Jacky in order to obtain solid data.

From the referenced presentation itself it's hard to tell, if they tested against 11.1-RELEASE (with/out patch) or 11-STABLE.
Comment 11 Lutz Donnerhacke freebsd_committer freebsd_triage 2018-05-22 10:18:54 UTC
Jacky provided additional information (at lot of ...)

They tested again using "11.1-RELEASE #0 r321309".
First question is, if this version did contain the patch or not.
Comment 12 Nick Hilliard 2018-05-22 10:24:51 UTC
r321309 was 11.1-RELEASE, dated 2017-07-20.  The fix was commit r327337, dated 2017-12-29.  Looks like she may have tested the wrong version :-(
Comment 13 Lutz Donnerhacke freebsd_committer freebsd_triage 2018-05-29 16:02:55 UTC
Waiting for rechecks from Jacky.
Changed state according to best knowledge so far.