<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="no"?>
<?rfc tocompact="no"?>
<?rfc tocdepth="6"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<rfc category="info" docName="draft-ietf-karp-bfd-analysis-03"
     ipr="trust200902">
  <front>
    <title abbrev="BFD Gap Analysis">Analysis of Bidirectional Forwarding
    Detection (BFD) Security According to KARP Design Guide</title>

    <author fullname="Manav Bhatia" initials="M.B." surname="Bhatia">
      <organization>Alcatel-Lucent</organization>

      <address>
        <postal>
          <street/>

          <city>Bangalore</city>

          <code/>

          <region/>

          <country>India</country>
        </postal>

        <phone/>

        <email>manav.bhatia@alcatel-lucent.com</email>
      </address>
    </author>

    <author fullname="Dacheng Zhang" initials="D." surname="Zhang">
      <organization>Huawei Technologies co., LTD.</organization>

      <address>
        <postal>
          <street/>

          <city>Beijing</city>

          <region/>

          <code/>

          <country>China</country>
        </postal>

        <phone/>

        <facsimile/>

        <email>zhangdacheng@huawei.com</email>

        <uri/>
      </address>
    </author>

    <author fullname="Mahesh Jethanandani" initials="M.J."
            surname="Jethanandani">
      <organization>Ciena Corporation</organization>

      <address>
        <postal>
          <street>3939 North 1st Street</street>

          <city>San Jose</city>

          <region>CA</region>

          <code>95134</code>

          <country>USA</country>
        </postal>

        <phone>408.904.2160</phone>

        <facsimile>408.436.5582</facsimile>

        <email>mjethanandani@gmail.com</email>

        <uri/>
      </address>
    </author>

    <date day="19" month="June" year="2014"/>

    <abstract>
      <t>This document analyzes the Bidirectional Forwarding Detection
      protocol (BFD) according to the guidelines set forth in section 4.2 of
      KARP Design Guidelines [RFC6518].</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>This document performs a gap analysis of the current state of <xref
      target="RFC5880">Bidirectional Forwarding Detection </xref> according to
      the requirements of <xref target="RFC6518">KARP Design
      Guidelines</xref>. Previously, the OPSEC working group has provided an
      analysis of cryptographic issues with BFD in <xref
      target="RFC6039">Issues with Existing Cryptographic Protection Methods
      for Routing Protocols </xref>.</t>

      <t>The existing BFD specifications provide a basic security solution.
      Key ID is provided so that the key used in securing a packet can be
      changed on demand. Two cryptographic algorithms (MD5 and SHA-1) are
      supported for integrity protection of the control packets; the
      algorithms are both demonstrated to be subject to collision attacks.
      Routing protocols like <xref target="RFC4822">RIPv2 Cryptographic
      Authentication </xref>, <xref target="RFC5310">IS-IS Generic
      Cryptographic Authentication </xref> and <xref target="RFC5709">OSPFv2
      HMAC-SHA Cryptographic Authentication </xref> have started to use BFD
      for liveliness check. Moving the routing protocols to a stronger
      algorithm while using weaker algorithm for BFD would require the
      attacker to bring down BFD in order to bring down the routing protocol.
      BFD therefore needs to match the routing protocols in its strength of
      algorithm.</t>

      <t>While BFD uses a non-decreasing per-packet sequence number to protect
      itself from intra-connection replay attacks, it still leaves the
      protocol vulnerable to the inter-session replay attacks.</t>
    </section>

    <section title="Requirements to Meet ">
      <t>There are several requirements described in section 3 of <xref
      target="RFC6862">The Threat Analysis and Requirements for Cryptographic
      Authentication of Routing Protocols' Transports</xref> that BFD does not
      currently meet:</t>

      <t><list style="empty">
          <t>Replay Protection: BFD provides an incomplete intra-session and
          no inter-session replay attack protection; this creates significant
          denial-of-service opportunities.</t>

          <t>Strong Algorithms: the cryptographic algorithms adopted for
          message authentication in BFD are MD5 or SHA-1 based. However, both
          algorithms are known to be vulnerable to collision attacks. <xref
          target="I-D.ietf-bfd-generic-crypto-auth">BFD Generic Cryptographic
          Authentication </xref> and <xref
          target="I-D.ietf-bfd-hmac-sha">Authenticating BFD using HMAC-SHA-2
          procedures </xref> together propose a solution to support HMAC with
          the SHA-2 family of hash functions for BFD.</t>

          <t>DoS Attacks: BFD packets can be sent at millisecond intervals
          (the protocol uses timers at microsecond intervals). When malicious
          packets are sent at short intervals, with the authentication bit
          set, it can cause a DoS attack.</t>
        </list>The remainder of this document explains the details of how
      these requirements fail to be met and proposes mechanisms for addressing
      them.</t>
    </section>

    <section title="Current State of Security Methods">
      <t><xref target="RFC5880">BFD </xref> describes five authentication
      mechanisms for the integrity protection of BFD control packets: Simple
      Password, Keyed MD5 <xref target="RFC1321">The MD5 Message-Digest
      Algorithm </xref>, Meticulous Keyed MD5, Keyed SHA-1 and Meticulous
      SHA-1. In the simple password mechanism, every control packet is
      associated with a password transported in plain text; attacks
      eavesdropping the network traffic can easily learn the password and
      compromise the security of the corresponding BFD session. In the Keyed
      MD5 and the Meticulous Keyed MD5 mechanisms, BFD nodes use share secret
      keys to generate keyed MD5 digests for control packets. Similarly, in
      the Keyed SHA-1 and the Meticulous Keyed SHA-1 mechanisms, BFD nodes use
      shared secret keys to generate keyed SHA-1 digests for control packets.
      Note that in the keyed authentication mechanisms, every BFD control
      packet is associated with a non-decreasing 32-bit sequence number to
      resist replay attacks. In the Keyed MD5 and the Keyed SHA-1 mechanisms,
      the sequence member is only required to increase occasionally. However,
      in the Meticulous Keyed MD5 and the Meticulous Keyed SHA-1 mechanisms,
      the sequence member is required to monotonically increase with each
      successive packet.</t>

      <t>Additionally, limited key updating functionality is provided. There
      is a Key ID in every authenticated BFD control packet, indicating the
      key used to hash the packet. However, there is no mechanism described to
      provide a smooth key rollover that the BFD routers can use when moving
      from one key to the other.</t>

      <t>The BFD session timers are defined with the granularity of
      microseconds, and it is common in practice to send BFD packets at
      millisecond intervals. Since the cryptographic sequence number space is
      only 32 bits, a sequence number used in a BFD session may reach its
      maximum value and roll over within limited period. For instance, if a
      sequence number is increased by one every 3.3 millisecond, then it will
      reach its maximum value in less than 24 weeks. This can result in
      potential inter-session replay attacks especially when BFD uses the
      non-meticulous authentication modes.</t>

      <t>Note that when using authentication mechanisms, BFD requests the
      sequence of a received BFD packets drops with a limited range (3*
      Detection time multiplier). Therefore, when meticulous authentication
      modes are used, a replayed BFD packet will be rejected if it cannot fit
      into a relatively short window (3 times of the detect interval of the
      session). This introduces some difficulties for replaying packets.
      However, in a non-meticulous authentication mode, such windows can be
      large as sequence numbers are only increased occasionally, thus making
      it easier to perform replay attacks .</t>

      <t>In a BFD session, each node needs to select a 32-bit discriminator to
      identify itself. Therefore, a BFD session is identified by two
      discriminators. If a node will randomly select a new discriminator for a
      new session and use authentication mechanism to secure the control
      packets, inter-session replay attacks can be mitigated to some extent.
      However, in existing BFD demultiplexing mechanisms, the discriminators
      used in a new BFD session may be predictable. In some deployment
      scenarios, the discriminators of BFD routers may be decided by the
      destination and source addresses. So, if the sequence number of a BFD
      router rolls over for some reasons (e.g., reboot), the discriminators
      used to identify the new session will be identical to the ones used in
      the previous session. This makes performing a reply attack relatively
      simple.</t>

      <t>BFD allows a mode called the echo mode. Echo packets are not defined
      in the BFD specification, though they can keep the BFD session up. The
      format of the echo packet is local to the sending side and there are no
      guidelines on the properties of these packets beyond the choice of the
      source and destination addresses. While the BFD specification recommends
      applying security mechanisms to prevent spoofing of these packets, there
      are no guidelines on what type of mechanisms are appropriate.</t>
    </section>

    <section title="Impacts of BFD Replays ">
      <t>As discussed, BFD cannot meet the requirements of inter-session or
      intra-session replay protection. This section discusses the impacts of
      BFD replays.</t>

      <t>When cryptographic authentication mechanisms are adopted for BFD, a
      non-decreasing 32-bit long sequence number is used. In the Keyed MD5 and
      the Keyed SHA-1 mechanisms, the sequence member is not required to
      increase for every packet. Therefore an attacker can keep replaying the
      packets with the latest sequence number until the sequence number is
      updated. This issue is eliminated in the Meticulous Keyed MD5 and the
      Meticulous Keyed SHA-1 mechanisms. However, note that a sequence number
      may reach its maximum and be rolled over in a session. In this case,
      without the support from a automatic key management mechanism, the BFD
      session will be vulnerable to replay attacks performed by sending the
      packets before the roll over of the sequence number. For instance, an
      attacker can replay a packet with a sequence number which is larger than
      the current one. If the replayed packet is accepted, the victim will
      reject the legal packets whose sequence members are less than the one in
      the replayed packet. Therefore, the attacker can get a good chance to
      bring down the BFD session.</t>

      <t>Additionally, the BFD specification allows for the change of
      authentication state based on the state of a received packet. For
      instance, according to <xref target="RFC5880">BFD </xref>, if the state
      of a accepted packet is down, the receiver of the packet needs to
      transfer its state to down as well. Therefore, an elaborately selected
      replayed packet can cause a serious denial-of-service attack.</t>

      <t>BFD does not provide any solution to deal with inter-session replay
      attacks. If two subsequent BFD sessions adopt an identical discriminator
      pair and use the same cryptographic key to secure the control packets,
      it is intuitive to use a malicious authenticated packet (stored from the
      past session) to perform inter-connection replay attacks.</t>

      <t>Any security issues in the BFD echo mode will directly affect the BFD
      protocol and session states, and hence the network stability. For
      instance, any replay attacks would be indistinguishable from normal
      forwarding of the tested router. An attack would still cause a faulty
      link to be believed to be up, but there is little that can be done about
      it. However, if the echo packets are guessable, it may be possible to
      spoof from an external source and cause BFD to believe that a one-way
      link is really bidirectional. As a result, it is important that the echo
      packets contain random material that is also checked upon reception.</t>
    </section>

    <section title="Impact of New Authentication Requirements">
      <t>BFD can be run in software or hardware. Hardware implementations run
      BFD at a much smaller timeout, typically in the order of few
      milliseconds. For instance with a timeout of 3.3 milliseconds, a BFD
      session is required to send or receive 3 packets every 10 milliseconds.
      Software implementations typically run with a timeout in hundreds of
      milliseconds.</t>

      <t>Additionally, it is not common to find hardware support for computing
      the authentication data for the BFD session in hardware or software. In
      the keyed MD5 and Keyed SHA-1 implementation where the sequence number
      does not increase with every packet, software can be used to compute the
      authentication data. This is true if the time between increasing
      sequence number is long enough to compute the data in software. The
      ability to compute the hash in software is difficult with Meticulous
      Keyed MD5 and Meticulous Keyed SHA-1 if the time interval between
      transmits or between receives is small.</t>

      <t>Implementors should assess the impact of authenticating BFD sessions
      on their platform.</t>
    </section>

    <section title="Considerations for improvement">
      <t>This section suggests changes that can be adopted to improve the
      protection of BFD.</t>

      <t>As mentioned in section 3, a 32 bit sequence number space can wrap
      around in less than 24 weeks when set for the minimum time interval of
      3.3 milliseconds. To prevent a replay attack the sequence number can be
      tied to notion of real time where part of the sequence number reflects
      say the UTC time. A replay attack therefore can easily be detected.
      However, it does require that the two stations exchanging BFD packets
      are synchronized with respect to time. Alternatively, the sequence
      number can be a nonce number generated using the shared key. But nonce
      numbers will also run out in 24 weeks.</t>

      <t>Increasing the sequence number space to 64 bits makes the wrap around
      time be a little less than 2 million years. Combined with nonce or part
      of the number reflecting real time would make replay attacks difficult
      if not impossible.</t>

      <t>The security risks brought by SHA-1 and MD5 have been well
      understood. However, when using stronger digest algorithm, e.g., SHA-2,
      the imposed computing overhead will seriously affect the performance of
      BFD implementation. In order to make the trade-off between the strong
      algorithm requirement and the imposed overhead, Galois Message
      Authentication Code (GMAC) can be a candidate option. This algorithm is
      relative effective and has been supported by IPsec for data origin
      authentication. More detailed information can be found in <xref
      target="RFC4543">The Use of GMAC in IPsec ESP and AH </xref>.</t>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <t>This document makes no request of IANA.</t>

      <t>Note to RFC Editor: this section may be removed on publication as an
      RFC.</t>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>This document discusses vulnerabilities in the existing BFD protocol
      and suggests possible mitigations.</t>

      <t>In analyzing the improvements for BFD the ability to repel a replay
      attack is discussed. For example, if part of the sequence number can be
      tied to a real time clock such as UTC, a replay attack can be easily
      prevented. Also increasing the sequence number to a 64bit value makes
      the wrap around time much longer.</t>

      <t>Mindful of the impact that stronger algorithms can have on the
      performance of BFD, the document suggests GMAC as a possible candidate
      for MAC function.</t>
    </section>

    <section anchor="Acknowledgements" title="Acknowledgements">
      <t>We would like to thank Alexander Vainshtein for his comments on this
      document.</t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include='reference.RFC.1321'?>

      <?rfc include='reference.RFC.6039'?>

      <?rfc include='reference.RFC.5880'?>
    </references>

    <references title="Informative References">
      <?rfc include='reference.RFC.6862'?>

      <?rfc include='reference.I-D.ietf-bfd-generic-crypto-auth'?>

      <?rfc include='reference.I-D.ietf-bfd-hmac-sha'?>

      <?rfc include='reference.RFC.4822'?>

      <?rfc include='reference.RFC.5310'?>

      <?rfc include='reference.RFC.4543'?>

      <?rfc include='reference.RFC.5709'
?>

      <?rfc include='reference.RFC.6518'?>
    </references>
  </back>
</rfc>
