<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE rfc>
<rfc version='3' 
     docName='draft-ietf-babel-mac-relaxed-01'
     ipr='trust200902'
     consensus='true'
     submissionType='IETF'
     category='std'
     updates='8967'
     xml:lang='en'
     xmlns:xi="http://www.w3.org/2001/XInclude">
<front>
<title abbrev='Babel-MAC Relaxed PC'>
Relaxed Packet Counter Verification for Babel MAC Authentication
</title>

<author fullname="Juliusz Chroboczek" initials="J." surname="Chroboczek">
<organization>IRIF, University of Paris-Cité</organization>
<address>
<postal>
<street>Case 7014</street>
<city>Paris CEDEX 13</city>
<code>75205</code>
<country>France</country>
</postal>
<email>jch@irif.fr</email>
</address>
</author>

<author fullname='Toke Høiland-Jørgensen' initials='T.'
        surname='Høiland-Jørgensen'>
  <organization>Red Hat</organization>
  <address>
    <email>toke@toke.dk</email>
  </address>
</author>

<date year='2022' month='June' day='11'/>

<abstract>
<t>This document relaxes packet verification rules defined in the Babel
MAC Authentication protocol in order to make it more robust in the
presence of packet reordering.</t>
</abstract>
</front>

<middle>

<section><name>Introduction</name>

<t>The design of the Babel MAC authentication mechanism <xref
target="RFC8967"/> assumes that packet reordering is an exceptional
occurrence, and the protocol drops any packets that arrive out-of-order.
This assumption is generally correct on wired links, but turns out to be
incorrect on some kinds of wireless links.</t>

<t>In particular, IEEE 802.11 (WiFi) defines a number of power-saving
modes that allow stations (mobile nodes) to switch their radio off for
extended periods of time, ranging in the hundreds of milliseconds.  The
access point (network switch) buffers all multicast packets, and only
sends them out after the power-saving interval ends.  The result is that
multicast packets are delayed by up to a few hundred milliseconds with
respect to unicast packets, which, under some traffic patterns, causes the
PC verification procedure in RFC 8967 to systematically fail for multicast
packets.</t>

<t>This document defines two ways to relax the PC validation: using two
separate receiver-side states, one for unicast and one for multicast
packets (<xref target="separate-pc"/>), and using a window of previously
received PC values (<xref target="window"/>).  Usage of the former is
RECOMMENDED, while usage of the latter is OPTIONAL.  The two MAY be used
simultaneously (<xref target="combining"/>).  This document updates RFC
8967.</t>

</section>

<section><name>Specification of Requirements</name>

<t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in BCP 14
<xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when,
they appear in all capitals, as shown here.</t>

</section>

<section><name>Relaxing PC validation</name>

<t>The Babel MAC authentication mechanism prevents replay by decorating
every sent packet with a strictly increasing value, the Packet Counter
(PC).  Notwithstanding the name, the PC does not actually count packets:
it is permitted for a sender to increment the PC by more than one between
two packets.</t>

<t>A receiver maintains the highest PC received from each neighbour.  When
a new packet is received, the receiver compares the PC contained in the
packet with the highest received PC; if the new value is smaller or equal,
the packet is discarded; otherwise, the packet is accepted, and the highest
PC value for that neighbour is updated.</t>

<t>Note that there does not exist a one-to-one correspondence between
sender states and receiver states: multiple receiver states track a single
sender state.  The receiver states corresponding to single sender state
are not necessarily identical, since only a subset of receiver states are
updated when a packet is sent to a unicast address or when a multicast
packet is received by a subset of the receivers.</t>

<section anchor="separate-pc"><name>Multiple highest PC values</name>

<t>Instead of a single highest PC value maintained for each neighbour, an
implementation of the procedure described in this section uses two values,
the highest unicast PC and the highest multicast PC.  More precisely, the
(Index, PC) pair contained in the Neighbour Table (<relref
target="RFC8967" section="3.2"/>) is replaced by:</t>
<ul>
<li>a triple (Index, PCm, PCu), where Index is an arbitrary string of 0 to
32 octets, and PCm and PCu are 32-bit (4-octet) integers.</li>
</ul>

<t>When a challenge reply is successful, both highest PC values are updated
to the value contained in PC TLV from the packet containing the successful
challenge.  More precisely, the last sentence of the fourth bullet point
of <relref target="RFC8967" section="4.3"/> is replaced by:</t>
<ul>
<li>If the packet contains a successful Challenge Reply, then the Index
contained in the PC TLV MUST be stored in the Index field of the Neighbour
Table entry corresponding to the sender packet is accepted, and the PC
contained in the TLV MUST be stored in both the PCm and PCu fields of the
Neighbour Table entry.</li>
</ul>

<t>When a packet that does not contain a successful challenge reply is
received, then the PC value it contains is compared to either the PCm or
the PCu field of the corresponding neighbour entry, depending on whether
the packet was sent to a unicast or a multicast address.  If the
comparison is successful, then the same value (PCm or PCu) is updated.
More precisely, the last bullet point of <relref target="RFC8967"
section="4.3"/> is replaced by:</t>
<ul>
<li>At this stage, the packet contains no successful challenge reply and
the Index contained in the PC TLV is equal to the Index in the Neighbour
Table entry corresponding to the sender.  The receiver compares the
received PC with either PCm field (if the packet was sent to a multicast
address) or the PCu field (otherwise) in the Neighbour Table; if the
received PC is smaller or equal than the value contained in the Neighbour
Table, the packet MUST be dropped and processing stops (no challenge is
sent in this case, since the mismatch might be caused by harmless packet
reordering on the link).  Otherwise, the PCm (if the packet was sent to
a multicast address) or the PCu (otherwise) field contained in the
Neighbour Table entry is set to the received PC, and the packet is
accepted.</li>
</ul>

<section><name>Generalisations</name>

<t>Modern networking hardware tends to maintain more than just two queues,
and it might be tempting to generalise the approach taken to more than
just two last PC values.  For example, one might be tempted to use
distinct last PC values for packets received with different values of the
Type of Service (ToS) field, or with different IEEE 802.11e access
categories.  However, chosing a highest PC field by consulting a value that
is not protected by the MAC (<relref target="RFC8967" section="4.1"/>)
would no longer protect against replay.  In practice, this means that only
the destination address and port number and data stored in the packet body
may be used for choosing the highest PC value, since these are the only
fields that are protected by the MAC (in addition to the source address
and porte number, which are already used when choosing the Neighbour Table
entry and therefore provide no additional information).</t>

<t>The following example shows why it would be unsafe to select the highest
PC depending on the ToS field.  Suppose that a node B were to maintain
distinct highest PC values for different values T1 and T2 of the ToS field,
and that initially all of the highest PC fields at B have value 42.  Suppose
now that a node A sends a packet P1 with ToS equal to T1 and PC equal to
43; when B receives the packet, it sets the highest PC value associated with
ToS T1 to 43.  If an attacker were now to send an exact copy of P1 but
with ToS equal to T2, B would consult the highest PC value associated with
T2, which is still equal to 42, and accept the replayed packet.</t>
</section>

</section>

<section anchor="window"><name>Window-based validation</name>

<t>Window-based validation is similar to that described in <relref
target="RFC4303" section="3.4.3"/>. When using window-based validation, in
addition to remembering the highest PC value seen from a given neighbour, an
implementation maintains a fixed-size window of individual sequence numbers
below this highest PC value. The PC value itself is updated if the new packet PC
value is higher than the existing value being remembered, while the window is
used to track individual values so that out-of-order PC values can be accepted
without allowing any duplicates.</t>

<t>Conceptually, the window is a vector of S boolean values numbered from
0 (the "left edge" of the window) up to (S - 1) (the "right edge").  Thus,
the window can be stored as a fixed-size bitmap, but other more
complicated data structures are also possible.  Shifting the window to the
left by an integer amount k consists in moving all values so that the
value previously at index n is now at index (n - k); k values are
discarded at the left edge, and k new unset values are inserted at the
right edge.</t>

<t>Whenever a packet is received, its PC value is first compared with the
PC value kept in the neighbour table, and the <em>window index</em> of the
received PC value is computed as the difference between the received PC
value and the stored highest PC value plus the window size.</t>

<ol>
  <li>If the window index is negative, the packet is considered too old
  and MUST be discarded.</li>

  <li>If the window index is non-negative and less than or equal to the
  size of the window, the window value at the window index is checked; if
  this value is already set, the received PC has been seen before and the
  packet MUST be discarded.  Otherwise, the corresponding window value is
  marked as set, and the packet is accepted.</li>

  <li>If the window index is larger than the window size (i.e., the
  received PC is higher than the largest received value), the window MUST
  be shifted to the left by the difference between the window index and
  the window size (or, equivalently, by the difference between the
  received PC and the highest PC stored in the neighbour table) and the
  highest PC value MUST be set to the received PC.  The value at the right
  of the window (the value numbered S - 1) MUST be set, and the packet is
  accepted.</li>
</ol>

<t>When receiving a successful Challenge Reply, the remembered highest PC
value MUST be set to the value received in the challenge reply, and all of
the values in the window MUST be reset.</t>

</section>

<section anchor="combining"><name>Combining the two techniques</name>

<t>The two techniques defined above serve complementar purposes: splitting
the state allows multicast packets to be reordered with respect to unicast
ones by an arbitrary number of PC values, while the window-based technique
allows arbitrary packets to be reordered but only by a bounded number of
PC values.  Thus, they can profitably be combined.</t>

<t>An implementation of both techniques MUST maintain, for every entry of
the Neighbour table, two distinct windows, one for multicast and one for
unicast packets.  When a successful challenge reply is received, both
windows MUST be reset.  When a packet that does not contain a challenge
reply is received, then if the packet's destination address is a multicast
address, the multicast window MUST be consulted and possibly updated, as
described in <xref target="window"/>; otherwise, the unicast window MUST
be consluted and possibly updated.</t>

</section>

</section>

<section><name>Security considerations</name>

<t>The procedures described in this document do not change the security
properties described in Section 1.2 of RFC 8967.  While they do slightly
increase the amount of per-neighbour state maintained by each node, this
increase is marginal (between 4 and 32 octets, depending on implementation
choices), and should not significantly impact the ability of nodes to
survive denial-of-service attacks.</t>

</section>

<section title="Acknowledgments">

<t>The authors are indebted to Daniel Gröber, who first identified the
problem that the procedures in this document aim to solve.</t>

</section>

</middle>

<back>
<references><name>Normative references</name>

<reference anchor="RFC8967" target="https://www.rfc-editor.org/info/rfc8967">
<front>
<title>MAC Authentication for the Babel Routing Protocol</title>
<author initials="C." surname="Dô" fullname="C. Dô"/>
<author initials="W." surname="Kolodziejak" fullname="W. Kolodziejak"/>
<author initials="J." surname="Chroboczek" fullname="J. Chroboczek"/>
<date year="2021" month="January"/>
</front>
<seriesInfo name="RFC" value="8967"/>
<seriesInfo name="DOI" value="10.17487/RFC8967"/>
</reference>

<reference anchor="RFC2119"><front>
<title>Key words for use in RFCs to Indicate Requirement Levels</title>
<author initials="S." surname="Bradner" fullname="S. Bradner"/>
<date year="1997" month="March"/>
</front>
<seriesInfo name="BCP" value="14"/>
<seriesInfo name="RFC" value="2119"/>
<seriesInfo name="DOI" value="10.17487/RFC2119"/>
</reference>

<reference anchor="RFC8174"><front>
<title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
<author initials="B." surname="Leiba" fullname="B. Leiba"/>
<date year="2017" month="May"/>
</front>
<seriesInfo name="BCP" value="14"/>
<seriesInfo name="RFC" value="8174"/>
<seriesInfo name="DOI" value="10.17487/RFC8174"/>
</reference>

</references>

<references><name>Informative references</name>

<reference  anchor='RFC4303' target='https://www.rfc-editor.org/info/rfc4303'>

<front>
<title>IP Encapsulating Security Payload (ESP)</title>
<author initials='S.' surname='Kent' fullname='S. Kent'/>
<date year='2005' month='December' />
</front>
<seriesInfo name='RFC' value='4303'/>
<seriesInfo name='DOI' value='10.17487/RFC4303'/>
</reference>

</references>

</back>
</rfc>
  

