idnits 2.17.1 draft-ietf-babel-hmac-05.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- -- The draft header indicates that this document updates RFC6126bis, but the abstract doesn't seem to mention this, which it should. -- The abstract seems to indicate that this document updates RFC6126, but the header doesn't have an 'Updates:' line to match this. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (June 7, 2019) is 1756 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) ** Downref: Normative reference to an Informational RFC: RFC 2104 == Outdated reference: A later version (-20) exists of draft-ietf-babel-rfc6126bis-06 ** Downref: Normative reference to an Informational RFC: RFC 6234 ** Downref: Normative reference to an Informational RFC: RFC 7693 == Outdated reference: A later version (-10) exists of draft-ietf-babel-dtls-01 -- Obsolete informational reference (is this intentional?): RFC 7298 (Obsoleted by RFC 8967) Summary: 3 errors (**), 0 flaws (~~), 3 warnings (==), 4 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group C. Do 3 Internet-Draft W. Kolodziejak 4 Obsoletes: 7298 (if approved) J. Chroboczek 5 Updates: 6126bis (if approved) IRIF, University of Paris-Diderot 6 Intended status: Standards Track June 7, 2019 7 Expires: December 9, 2019 9 HMAC authentication for the Babel routing protocol 10 draft-ietf-babel-hmac-05 12 Abstract 14 This document describes a cryptographic authentication mechanism for 15 the Babel routing protocol that has provisions for replay avoidance. 16 This document updates RFC 6126bis and obsoletes RFC 7298. 18 Status of This Memo 20 This Internet-Draft is submitted in full conformance with the 21 provisions of BCP 78 and BCP 79. 23 Internet-Drafts are working documents of the Internet Engineering 24 Task Force (IETF). Note that other groups may also distribute 25 working documents as Internet-Drafts. The list of current Internet- 26 Drafts is at https://datatracker.ietf.org/drafts/current/. 28 Internet-Drafts are draft documents valid for a maximum of six months 29 and may be updated, replaced, or obsoleted by other documents at any 30 time. It is inappropriate to use Internet-Drafts as reference 31 material or to cite them other than as "work in progress." 33 This Internet-Draft will expire on December 9, 2019. 35 Copyright Notice 37 Copyright (c) 2019 IETF Trust and the persons identified as the 38 document authors. All rights reserved. 40 This document is subject to BCP 78 and the IETF Trust's Legal 41 Provisions Relating to IETF Documents 42 (https://trustee.ietf.org/license-info) in effect on the date of 43 publication of this document. Please review these documents 44 carefully, as they describe your rights and restrictions with respect 45 to this document. Code Components extracted from this document must 46 include Simplified BSD License text as described in Section 4.e of 47 the Trust Legal Provisions and are provided without warranty as 48 described in the Simplified BSD License. 50 Table of Contents 52 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 53 1.1. Applicability . . . . . . . . . . . . . . . . . . . . . . 3 54 1.2. Assumptions and security properties . . . . . . . . . . . 3 55 1.3. Specification of Requirements . . . . . . . . . . . . . . 4 56 2. Conceptual overview of the protocol . . . . . . . . . . . . . 4 57 3. Data Structures . . . . . . . . . . . . . . . . . . . . . . . 6 58 3.1. The Interface Table . . . . . . . . . . . . . . . . . . . 6 59 3.2. The Neighbour table . . . . . . . . . . . . . . . . . . . 6 60 4. Protocol Operation . . . . . . . . . . . . . . . . . . . . . 7 61 4.1. HMAC computation . . . . . . . . . . . . . . . . . . . . 7 62 4.2. Packet Transmission . . . . . . . . . . . . . . . . . . . 8 63 4.3. Packet Reception . . . . . . . . . . . . . . . . . . . . 8 64 4.4. Expiring per-neighbour state . . . . . . . . . . . . . . 11 65 5. Packet Format . . . . . . . . . . . . . . . . . . . . . . . . 12 66 5.1. HMAC TLV . . . . . . . . . . . . . . . . . . . . . . . . 12 67 5.2. PC TLV . . . . . . . . . . . . . . . . . . . . . . . . . 12 68 5.3. Challenge Request TLV . . . . . . . . . . . . . . . . . . 13 69 5.4. Challenge Reply TLV . . . . . . . . . . . . . . . . . . . 13 70 6. Security Considerations . . . . . . . . . . . . . . . . . . . 14 71 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 15 72 8. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 15 73 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 15 74 9.1. Normative References . . . . . . . . . . . . . . . . . . 15 75 9.2. Informational References . . . . . . . . . . . . . . . . 16 76 Appendix A. Incremental deployment and key rotation . . . . . . 16 77 Appendix B. Changes from previous versions . . . . . . . . . . . 17 78 B.1. Changes since draft-ietf-babel-hmac-00 . . . . . . . . . 17 79 B.2. Changes since draft-ietf-babel-hmac-01 . . . . . . . . . 17 80 B.3. Changes since draft-ietf-babel-hmac-02 . . . . . . . . . 17 81 B.4. Changes since draft-ietf-babel-hmac-03 . . . . . . . . . 18 82 B.5. Changes since draft-ietf-babel-hmac-04 . . . . . . . . . 18 83 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 18 85 1. Introduction 87 By default, the Babel routing protocol trusts the information 88 contained in every UDP datagram that it receives on the Babel port. 89 An attacker can redirect traffic to itself or to a different node in 90 the network, causing a variety of potential issues. In particular, 91 an attacker might: 93 o spoof a Babel packet, and redirect traffic by announcing a smaller 94 metric, a larger seqno, or a longer prefix; 96 o spoof a malformed packet, which could cause an insufficiently 97 robust implementation to crash or interfere with the rest of the 98 network; 100 o replay a previously captured Babel packet, which could cause 101 traffic to be redirected or otherwise interfere with the network. 103 Protecting a Babel network is challenging due to the fact that the 104 Babel protocol uses both unicast and multicast communication. One 105 possible approach, used notably by the Babel over Datagram Transport 106 Layer Security (DTLS) protocol [I-D.ietf-babel-dtls], is to use 107 unicast communication for all semantically significant communication, 108 and then use a standard unicast security protocol to protect the 109 Babel traffic. In this document, we take the opposite approach: we 110 define a cryptographic extension to the Babel protocol that is able 111 to protect both unicast and multicast traffic, and thus requires very 112 few changes to the core protocol. 114 1.1. Applicability 116 The protocol defined in this document assumes that all interfaces on 117 a given link are equally trusted and share a small set of symmetric 118 keys (usually just one, and two during key rotation). The protocol 119 is inapplicable in situations where asymmetric keying is required, 120 where the trust relationship is partial, or where large numbers of 121 trusted keys are provisioned on a single link at the same time. 123 This protocol supports incremental deployment (where an insecure 124 Babel network is made secure with no service interruption), and it 125 supports graceful key rotation (where the set of keys is changed with 126 no service interruption). 128 This protocol does not require synchronised clocks, it does not 129 require persistently monotonic clocks, and it does not require 130 persistent storage except for what might be required for storing 131 cryptographic keys. 133 1.2. Assumptions and security properties 135 The correctness of the protocol relies on the following assumptions: 137 o that the Hashed Message Authentication Code (HMAC) being used is 138 invulnerable to pre-image attacks, i.e., that an attacker is 139 unable to generate a packet with a correct HMAC; 141 o that a node never generates the same index or nonce twice over the 142 lifetime of a key. 144 The first assumption is a property of the HMAC being used. The 145 second assumption can be met either by using a robust random number 146 generator [RFC4086] and sufficiently large indices and nonces, by 147 using a reliable hardware clock, or by rekeying whenever a collision 148 becomes likely. 150 If the assumptions above are met, the protocol described in this 151 document has the following properties: 153 o it is invulnerable to spoofing: any packet accepted as authentic 154 is the exact copy of a packet originally sent by an authorised 155 node; 157 o locally to a single node, it is invulnerable to replay: if a node 158 has previously accepted a given packet, then it will never again 159 accept a copy of this packet or an earlier packet from the same 160 sender; 162 o among different nodes, it is only vulnerable to immediate replay: 163 if a node A has accepted a packet from C as valid, then a node B 164 will only accept a copy of that packet as authentic if B has 165 accepted an older packet from C and B has received no later packet 166 from C. 168 While this protocol makes serious efforts to mitigate the effects of 169 a denial of service attack, it does not fully protect against such 170 attacks. 172 1.3. Specification of Requirements 174 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 175 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 176 "OPTIONAL" in this document are to be interpreted as described in BCP 177 14 [RFC2119] [RFC8174] when, and only when, they appear in all 178 capitals, as shown here. 180 2. Conceptual overview of the protocol 182 When a node B sends out a Babel packet through an interface that is 183 configured for HMAC cryptographic protection, it computes one or more 184 HMACs which it appends to the packet. When a node A receives a 185 packet over an interface that requires HMAC cryptographic protection, 186 it independently computes a set of HMACs and compares them to the 187 HMACs appended to the packet; if there is no match, the packet is 188 discarded. 190 In order to protect against replay, B maintains a per-interface 191 32-bit integer known as the "packet counter" (PC). Whenever B sends 192 a packet through the interface, it embeds the current value of the PC 193 within the region of the packet that is protected by the HMACs and 194 increases the PC by at least one. When A receives the packet, it 195 compares the value of the PC with the one contained in the previous 196 packet received from B, and unless it is strictly greater, the packet 197 is discarded. 199 By itself, the PC mechanism is not sufficient to protect against 200 replay. Consider a peer A that has no information about a peer B 201 (e.g., because it has recently rebooted). Suppose that A receives a 202 packet ostensibly from B carrying a given PC; since A has no 203 information about B, it has no way to determine whether the packet is 204 freshly generated or a replay of a previously sent packet. 206 In this situation, A discards the packet and challenges B to prove 207 that it knows the HMAC key. It sends a "challenge request", a TLV 208 containing a unique nonce, a value that has never been used before 209 and will never be used again. B replies to the challenge request 210 with a "challenge reply", a TLV containing a copy of the nonce chosen 211 by A, in a packet protected by HMAC and containing the new value of 212 B's PC. Since the nonce has never been used before, B's reply proves 213 B's knowledge of the HMAC key and the freshness of the PC. 215 By itself, this mechanism is safe against replay if B never resets 216 its PC. In practice, however, this is difficult to ensure, as 217 persistent storage is prone to failure, and hardware clocks, even 218 when available, are occasionally reset. Suppose that B resets its PC 219 to an earlier value, and sends a packet with a previously used PC n. 220 A challenges B, B successfully responds to the challenge, and A 221 accepts the PC equal to n + 1. At this point, an attacker C may send 222 a replayed packet with PC equal to n + 2, which will be accepted by 223 A. 225 Another mechanism is needed to protect against this attack. In this 226 protocol, every PC is tagged with an "index", an arbitrary string of 227 octets. Whenever B resets its PC, or whenever B doesn't know whether 228 its PC has been reset, it picks an index that it has never used 229 before (either by drawing it randomly or by using a reliable hardware 230 clock) and starts sending PCs with that index. Whenever A detects 231 that B has changed its index, it challenges B again. 233 With this additional mechanism, this protocol is invulnerable to 234 replay attacks (see Section 1.2 above). 236 3. Data Structures 238 Every Babel node maintains a set of conceptual data structures 239 described in Section 3.2 of [RFC6126bis]. This protocol extends 240 these data structures as follows. 242 3.1. The Interface Table 244 Every Babel node maintains an interface table, as described in 245 Section 3.2.3 [RFC6126bis]. Implementations of this protocol MUST 246 allow each interface to be provisioned with a set of one or more HMAC 247 keys and the associated HMAC algorithms (see Section 4.1). In order 248 to allow incremental deployment of this protocol (see Appendix A), 249 implementations SHOULD allow an interface to be configured in a mode 250 in which it participates in the HMAC authentication protocol but 251 accepts packets that are not authentified. 253 This protocol extends each entry in this table that is associated 254 with an interface on which HMAC authentication has been configured 255 with two new pieces of data: 257 o a set of one or more HMAC keys, each associated with a given HMAC 258 algorithm ; the length of each key is exactly the hash size of the 259 associated HMAC algorithm (i.e., the key is not subject to the 260 preprocessing described in Section 2 of [RFC2104]); 262 o a pair (Index, PC), where Index is an arbitrary string of 0 to 32 263 octets, and PC is a 32-bit (4-octet) integer. 265 We say that an index is fresh when it has never been used before with 266 any of the keys currently configured on the interface. The Index 267 field is initialised to a fresh index, for example by drawing a 268 random string of sufficient length, and the PC is initialised to an 269 arbitrary value (typically 0). 271 3.2. The Neighbour table 273 Every Babel node maintains a neighbour table, as described in 274 Section 3.2.4 of [RFC6126bis]. This protocol extends each entry in 275 this table with two new pieces of data: 277 o a pair (Index, PC), where Index is a string of 0 to 32 octets, and 278 PC is a 32-bit (4-octet) integer; 280 o a Nonce, which is an arbitrary string of 0 to 192 octets, and an 281 associated challenge expiry timer. 283 The Index and PC are initially undefined, and are managed as 284 described in Section 4.3. The Nonce and expiry timer are initially 285 undefined, and used as described in Section 4.3.1.1. 287 4. Protocol Operation 289 4.1. HMAC computation 291 A Babel node computes the HMAC of a Babel packet as follows. 293 First, the node builds a pseudo-header that will participate in HMAC 294 computation but will not be sent. If the packet was carried over 295 IPv6, the pseudo-header has the following format: 297 0 1 2 3 298 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 299 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 300 | | 301 + + 302 | | 303 + Src address + 304 | | 305 + + 306 | | 307 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 308 | Src port | | 309 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ + 310 | | 311 + + 312 | Dest address | 313 + + 314 | | 315 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 316 | | Dest port | 317 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 319 If the packet was carried over IPv4, the pseudo-header has the 320 following format: 322 0 1 2 3 323 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 324 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 325 | Src address | 326 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 327 | Src port | Dest address | 328 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 329 | | Dest port | 330 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 331 Fields : 333 Src address The source IP address of the packet. 335 Src port The source UDP port number of the packet. 337 Dest address The destination IP address of the packet. 339 Src port The destination UDP port number of the packet. 341 The node takes the concatenation of the pseudo-header and the packet 342 including the packet header but excluding the packet trailer (from 343 octet 0 inclusive up to (Body Length + 4) exclusive) and computes an 344 HMAC with one of the implemented hash algorithms. Every 345 implementation MUST implement HMAC-SHA256 as defined in [RFC6234] and 346 Section 2 of [RFC2104], SHOULD implement keyed BLAKE2s [RFC7693], and 347 MAY implement other HMAC algorithms. 349 4.2. Packet Transmission 351 A Babel node might delay actually sending TLVs by a small amount, in 352 order to aggregate multiple TLVs in a single packet up to the 353 interface MTU (Section 4 of [RFC6126bis]). For an interface on which 354 HMAC protection is configured, the TLV aggregation logic MUST take 355 into account the overhead due to PC TLVs (one in each packet) and 356 HMAC TLVs (one per configured key). 358 Before sending a packet, the following actions are performed: 360 o a PC TLV containing the PC and Index associated with the outgoing 361 interface MUST be appended to the packet body; the PC MUST be 362 incremented by a strictly positive amount (typically just 1); if 363 the PC overflows, a fresh index MUST be generated (as defined in 364 Section 3.1); 366 o for each key configured on the interface, an HMAC is computed as 367 specified in Section 4.1 above, and stored in an HMAC TLV that 368 MUST be appended to the packet trailer (see Section 4.2 of 369 [RFC6126bis]). 371 4.3. Packet Reception 373 When a packet is received on an interface that is configured for HMAC 374 protection, the following steps are performed before the packet is 375 passed to normal processing: 377 o First, the receiver checks whether the trailer of the received 378 packet carries at least one HMAC TLV; if not, the packet MUST be 379 immediately dropped and processing stops. Then, for each key 380 configured on the receiving interface, the receiver computes the 381 HMAC of the packet. It then compares every generated HMAC against 382 every HMAC included in the packet; if there is at least one match, 383 the packet passes the HMAC test; if there is none, the packet MUST 384 be silently dropped and processing stops at this point. In order 385 to avoid memory exhaustion attacks, an entry in the Neighbour 386 Table MUST NOT be created before the HMAC test has passed 387 successfully. The HMAC of the packet MUST NOT be computed for 388 each HMAC TLV contained in the packet, but only once for each 389 configured key. 391 o The packet body is then parsed a first time. During this 392 "preparse" phase, the packet body is traversed and all TLVs are 393 ignored except PC TLVs, Challenge Requests and Challenge Replies. 394 When a PC TLV is encountered, the enclosed PC and Index are saved 395 for later processing; if multiple PCs are found, only the first 396 one is processed, the remaining ones MUST be silently ignored. If 397 a Challenge Request is encountered, a Challenge Reply MUST be 398 scheduled, as described in Section 4.3.1.2. If a Challenge Reply 399 is encountered, it is tested for validity as described in 400 Section 4.3.1.3 and a note is made of the result of the test. 402 o The preparse phase above has yielded two pieces of data: the PC 403 and Index from the first PC TLV, and a bit indicating whether the 404 packet contains a successful Challenge Reply. If the packet does 405 not contain a PC TLV, the packet MUST be dropped and processing 406 stops at this point. If the packet contains a successful 407 Challenge Reply, then the PC and Index contained in the PC TLV 408 MUST be stored in the Neighbour Table entry corresponding to the 409 sender (which may need to be created at this stage), and the 410 packet is accepted. 412 o Otherwise, if there is no entry in the Neighbour 413 Table corresponding to the sender, or if such an entry exists but 414 contains no Index, or if the Index it contains is different from 415 the Index contained in the PC TLV, then a challenge MUST be sent 416 as described in Section 4.3.1.1, the packet MUST be dropped, and 417 processing stops at this stage. 419 o At this stage, the packet contains no successful challenge reply 420 and the Index contained in the PC TLV is equal to the Index in the 421 Neighbour Table entry corresponding to the sender. The receiver 422 compares the received PC with the PC contained in the Neighbour 423 Table; if the received PC is smaller or equal than the PC 424 contained in the Neighbour Table, the packet MUST be dropped and 425 processing stops (no challenge is sent in this case, since the 426 mismatch might be caused by harmless packet reordering on the 427 link). Otherwise, the PC contained in the Neighbour Table entry 428 is set to the received PC, and the packet is accepted. 430 After the packet has been accepted, it is processed as normal, except 431 that any PC, Challenge Request and Challenge Reply TLVs that it 432 contains are silently ignored. 434 4.3.1. Challenge Requests and Replies 436 During the preparse stage, the receiver might encounter a mismatched 437 Index, to which it will react by scheduling a Challenge Request. It 438 might encounter a Challenge Request TLV, to which it will reply with 439 a Challenge Reply TLV. Finally, it might encounter a Challenge Reply 440 TLV, which it will attempt to match with a previously sent Challenge 441 Request TLV in order to update the Neighbour Table entry 442 corresponding to the sender of the packet. 444 4.3.1.1. Sending challenges 446 When it encounters a mismatched Index during the preparse phase, a 447 node picks a nonce that it has never used with any of the keys 448 currently configured on the relevant interface, for example by 449 drawing a sufficiently large random string of bytes or by consulting 450 a strictly monotonic hardware clock. It MUST then store the nonce in 451 the entry of the Neighbour Table associated to the neighbour (the 452 entry might need to be created at this stage), initialise the 453 neighbour's challenge expiry timer to 30 seconds, and send a 454 Challenge Request TLV to the unicast address corresponding to the 455 neighbour. 457 A node MAY aggregate a Challenge Request with other TLVs; in other 458 words, if it has already buffered TLVs to be sent to the unicast 459 address of the neighbour, it MAY send the buffered TLVs in the same 460 packet as the Challenge Request. However, it MUST arrange for the 461 Challenge Request to be sent in a timely manner, as any packets 462 received from that neighbour will be silently ignored until the 463 challenge completes. 465 Since a challenge may be prompted by a packet replayed by an 466 attacker, a node MUST impose a rate limitation to the challenges it 467 sends; the limit SHOULD default to one challenge request every 300ms, 468 and MAY be configurable. 470 4.3.1.2. Replying to challenges 472 When it encounters a Challenge Request during the preparse phase, a 473 node constructs a Challenge Reply TLV by copying the Nonce from the 474 Challenge Request into the Challenge Reply. It MUST then send the 475 Challenge Reply to the unicast address from which the Challenge 476 Request was sent. 478 A node MAY aggregate a Challenge Reply with other TLVs; in other 479 words, if it has already buffered TLVs to be sent to the unicast 480 address of the sender of the Challenge Request, it MAY send the 481 buffered TLVs in the same packet as the Challenge Reply. However, it 482 MUST arrange for the Challenge Reply to be sent in a timely manner 483 (within a few seconds), and SHOULD NOT send any other packets over 484 the same interface before sending the Challenge Reply, as those would 485 be dropped by the challenger. 487 A challenge sent to a multicast address MUST be silently ignored. 489 4.3.1.3. Receiving challenge replies 491 When it encounters a Challenge Reply during the preparse phase, a 492 node consults the Neighbour Table entry corresponding to the 493 neighbour that sent the Challenge Reply. If no challenge is in 494 progress, i.e., if there is no Nonce stored in the Neighbour 495 Table entry or the Challenge timer has expired, the Challenge Reply 496 MUST be silently ignored and the challenge has failed. 498 Otherwise, the node compares the Nonce contained in the Challenge 499 Reply with the Nonce contained in the Neighbour Table entry. If the 500 two are equal (they have the same length and content), then the 501 challenge has succeeded; otherwise, the challenge has failed. 503 4.4. Expiring per-neighbour state 505 The per-neighbour (Index, PC) pair is maintained in the neighbour 506 table, and is normally discarded when the neighbour table entry 507 expires. Implementations MUST ensure that an (Index, PC) pair is 508 discarded within a finite time since the last time a packet has been 509 accepted. In particular, unsuccessful challenges MUST NOT prevent an 510 (Index, PC) pair from being discarded for unbounded periods of time. 512 A possible implementation strategy for implementations that use a 513 Hello history (Appendix A of [RFC6126bis]) is to discard the (Index, 514 PC) pair whenever the Hello history becomes empty. Another 515 implementation strategy is to use a timer that is reset whenever a 516 packet is accepted, and to discard the (Index, PC) pair whenever the 517 timer expires. If the latter strategy is being used, the timer 518 SHOULD default to a value of 5 min, and MAY be configurable. 520 5. Packet Format 522 5.1. HMAC TLV 524 0 1 2 3 525 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 526 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 527 | Type = 16 | Length | HMAC... 528 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 530 Fields : 532 Type Set to 16 to indicate an HMAC TLV. 534 Length The length of the body, in octets, exclusive of the Type 535 and Length fields. The length of the body depends on the 536 HMAC algorithm being used. 538 HMAC The body contains the HMAC of the packet, computed as 539 described in Section 4.1. 541 This TLV is allowed in the packet trailer (see Section 4.2 of 542 [RFC6126bis]), and MUST be ignored if it is found in the packet body. 544 5.2. PC TLV 546 0 1 2 3 547 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 548 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 549 | Type = 17 | Length | PC | 550 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 551 | | Index... 552 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 554 Fields : 556 Type Set to 17 to indicate a PC TLV. 558 Length The length of the body, in octets, exclusive of the Type 559 and Length fields. 561 PC The Packet Counter (PC), a 32-bit (4 octet) unsigned 562 integer which is increased with every packet sent over this 563 interface. A fresh index (as defined in Section 3.1) MUST 564 be generated whenever the PC overflows. 566 Index The sender's Index, an opaque string of 0 to 32 octets. 568 Indices are limited to a size of 32 octets: a node MUST NOT send a 569 TLV with an index of size strictly larger than 32 octets, and a node 570 MAY ignore a PC TLV with an index of size strictly larger than 32 571 octets. 573 5.3. Challenge Request TLV 575 0 1 2 3 576 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 577 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 578 | Type = 18 | Length | Nonce... 579 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 581 Fields : 583 Type Set to 18 to indicate a Challenge Request TLV. 585 Length The length of the body, in octets, exclusive of the Type 586 and Length fields. 588 Nonce The nonce uniquely identifying the challenge, an opaque 589 string of 0 to 192 octets. 591 Nonces are limited to a size of 192 octets: a node MUST NOT send a 592 Challenge Request TLV with a nonce of size strictly larger than 192 593 octets, and a node MAY ignore a nonce that is of size strictly larger 594 than 192 octets. 596 5.4. Challenge Reply TLV 598 0 1 2 3 599 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 600 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 601 | Type = 19 | Length | Nonce... 602 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 604 Fields : 606 Type Set to 19 to indicate a Challenge Reply TLV. 608 Length The length of the body, in octets, exclusive of the Type 609 and Length fields. 611 Nonce A copy of the nonce contained in the corresponding 612 challenge request. 614 6. Security Considerations 616 This document defines a mechanism that provides basic security 617 properties for the Babel routing protocol. The scope of this 618 protocol is strictly limited: it only provides authentication (we 619 assume that routing information is not confidential), it only 620 supports symmetric keying, and it only allows for the use of a small 621 number of symmetric keys on every link. Deployments that need more 622 features, e.g., confidentiality or asymmetric keying, should use a 623 more featureful security mechanism such as the one described in 624 [I-D.ietf-babel-dtls]. 626 This mechanism relies on two assumptions, as described in 627 Section 1.2. First, it assumes that the hash being used is 628 invulnerable to pre-image attacks (Section 1.1 of [RFC6039]); at the 629 time of writing, SHA-256, which is mandatory to implement 630 (Section 4.1), is believed to be safe against practical attacks. 632 Second, it assumes that indices and nonces are generated uniquely 633 over the lifetime of a key used for HMAC computation (more precisely, 634 indices must be unique for a given (key, source) pair, and nonces 635 must be unique for a given (key, source, destination) triple). This 636 property can be satisfied either by using a cryptographically secure 637 random number generator to generate indices and nonces that contain 638 enough entropy (64-bit values are believed to be large enough for all 639 practical applications), or by using a reliably monotonic hardware 640 clock. If uniqueness cannot be guaranteed (e.g., because a hardware 641 clock has been reset), then rekeying is necessary. 643 The expiry mechanism mandated in Section 4.4 is required to prevent 644 an attacker from delaying an authentic packet by an unbounded amount 645 of time. If an attacker is able to delay the delivery of a packet 646 (e.g., because it is located at a layer 2 switch), then the packet 647 will be accepted as long as the corresponding (Index, PC) pair is 648 present at the receiver. If the attacker is able to cause the 649 (Index, PC) pair to persist for arbitrary amounts of time (e.g., by 650 repeatedly causing failed challenges), then it is able to delay the 651 packet by arbitrary amounts of time, even after the sender has left 652 the network. 654 While it is probably not possible to be immune against denial of 655 service (DoS) attacks in general, this protocol includes a number of 656 mechanisms designed to mitigate such attacks. In particular, 657 reception of a packet with no correct HMAC creates no local state 658 whatsoever (Section 4.3). Reception of a replayed packet with 659 correct hash, on the other hand, causes a challenge to be sent; this 660 is mitigated somewhat by requiring that challenges be rate-limited. 662 At first sight, sending a challenge requires retaining enough 663 information to validate the challenge reply. However, the nonce 664 included in a challenge request and echoed in the challenge reply can 665 be fairly large (up to 192 octets), which should in principle permit 666 encoding the per-challenge state as a secure "cookie" within the 667 nonce itself. 669 7. IANA Considerations 671 IANA has allocated the following values in the Babel TLV Types 672 registry: 674 +------+-------------------+---------------+ 675 | Type | Name | Reference | 676 +------+-------------------+---------------+ 677 | 16 | HMAC | this document | 678 | | | | 679 | 17 | PC | this document | 680 | | | | 681 | 18 | Challenge Request | this document | 682 | | | | 683 | 19 | Challenge Reply | this document | 684 +------+-------------------+---------------+ 686 8. Acknowledgments 688 The protocol described in this document is based on the original HMAC 689 protocol defined by Denis Ovsienko [RFC7298]. The use of a pseudo- 690 header was suggested by David Schinazi. The use of an index to avoid 691 replay was suggested by Markus Stenberg. The authors are also 692 indebted to Donald Eastlake, Toke Hoiland-Jorgensen, Florian Horn, 693 and Dave Taht. 695 9. References 697 9.1. Normative References 699 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 700 Hashing for Message Authentication", RFC 2104, 701 DOI 10.17487/RFC2104, February 1997, 702 . 704 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 705 Requirement Levels", BCP 14, RFC 2119, 706 DOI 10.17487/RFC2119, March 1997. 708 [RFC6126bis] 709 Chroboczek, J. and D. Schinazi, "The Babel Routing 710 Protocol", draft-ietf-babel-rfc6126bis-06 (work in 711 progress), October 2018. 713 [RFC6234] Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms 714 (SHA and SHA-based HMAC and HKDF)", RFC 6234, 715 DOI 10.17487/RFC6234, May 2011, 716 . 718 [RFC7693] Saarinen, M-J., Ed. and J-P. Aumasson, "The BLAKE2 719 Cryptographic Hash and Message Authentication Code (MAC)", 720 RFC 7693, DOI 10.17487/RFC7693, November 2015, 721 . 723 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 724 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 725 May 2017. 727 9.2. Informational References 729 [I-D.ietf-babel-dtls] 730 Decimo, A., Schinazi, D., and J. Chroboczek, "Babel 731 Routing Protocol over Datagram Transport Layer Security", 732 draft-ietf-babel-dtls-01 (work in progress), October 2018. 734 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 735 "Randomness Requirements for Security", BCP 106, RFC 4086, 736 DOI 10.17487/RFC4086, June 2005, 737 . 739 [RFC6039] Manral, V., Bhatia, M., Jaeggli, J., and R. White, "Issues 740 with Existing Cryptographic Protection Methods for Routing 741 Protocols", RFC 6039, DOI 10.17487/RFC6039, October 2010, 742 . 744 [RFC7298] Ovsienko, D., "Babel Hashed Message Authentication Code 745 (HMAC) Cryptographic Authentication", RFC 7298, 746 DOI 10.17487/RFC7298, July 2014, 747 . 749 Appendix A. Incremental deployment and key rotation 751 This protocol supports incremental deployment (transitioning from an 752 insecure network to a secured network with no service interruption) 753 and key rotation (transitioning from a set of keys to a different set 754 of keys). 756 In order to perform incremental deployment, the nodes in the network 757 are first configured in a mode where packets are sent with 758 authentication but not checked on reception. Once all the nodes in 759 the network are configured to send authenticated packets, nodes are 760 reconfigured to reject unauthenticated packets. 762 In order to perform key rotation, the new key is added to all the 763 nodes; once this is done, both the old and the new key are sent in 764 all packets, and packets are accepted if they are properly signed by 765 either of the keys. At that point, the old key is removed. 767 In order to support incremental deployment and key rotation, 768 implementations SHOULD support an interface configuration in which 769 they send authenticated packets but accept all packets, and SHOULD 770 allow changing the set of keys associated with an interface without a 771 restart. 773 Appendix B. Changes from previous versions 775 [RFC Editor: please remove this section before publication.] 777 B.1. Changes since draft-ietf-babel-hmac-00 779 o Changed the title. 781 o Removed the appendix about the packet trailer, this is now in 782 rfc6126bis. 784 o Removed the appendix with implicit indices. 786 o Clarified the definitions of acronyms. 788 o Limited the size of nonces and indices. 790 B.2. Changes since draft-ietf-babel-hmac-01 792 o Made BLAKE2s a recommended HMAC algorithm. 794 o Added requirement to expire per-neighbour crypto state. 796 B.3. Changes since draft-ietf-babel-hmac-02 798 o Clarified that PCs are 32-bit unsigned integers. 800 o Clarified that indices and nonces are of arbitrary size. 802 o Added reference to RFC 4086. 804 B.4. Changes since draft-ietf-babel-hmac-03 806 o Use the TLV values allocated by IANA. 808 o Fixed an issue with packets that contain a successful challenge 809 reply: they should be accepted before checking the PC value. 811 o Clarified that keys are the exact value of the HMAC hash size, and 812 not subject to preprocessing; this makes management more 813 deterministic. 815 B.5. Changes since draft-ietf-babel-hmac-04 817 Use normative language in more places. 819 Authors' Addresses 821 Clara Do 822 IRIF, University of Paris-Diderot 823 75205 Paris Cedex 13 824 France 826 Email: clarado_perso@yahoo.fr 828 Weronika Kolodziejak 829 IRIF, University of Paris-Diderot 830 75205 Paris Cedex 13 831 France 833 Email: weronika.kolodziejak@gmail.com 835 Juliusz Chroboczek 836 IRIF, University of Paris-Diderot 837 Case 7014 838 75205 Paris Cedex 13 839 France 841 Email: jch@irif.fr