idnits 2.17.1 draft-ietf-babel-hmac-06.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 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 20, 2019) is 1772 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 (==), 3 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 Intended status: Standards Track IRIF, University of Paris-Diderot 6 Expires: December 22, 2019 June 20, 2019 8 HMAC authentication for the Babel routing protocol 9 draft-ietf-babel-hmac-06 11 Abstract 13 This document describes a cryptographic authentication mechanism for 14 the Babel routing protocol that has provisions for replay avoidance. 15 This document updates RFC 6126bis and obsoletes RFC 7298. 17 Status of This Memo 19 This Internet-Draft is submitted in full conformance with the 20 provisions of BCP 78 and BCP 79. 22 Internet-Drafts are working documents of the Internet Engineering 23 Task Force (IETF). Note that other groups may also distribute 24 working documents as Internet-Drafts. The list of current Internet- 25 Drafts is at https://datatracker.ietf.org/drafts/current/. 27 Internet-Drafts are draft documents valid for a maximum of six months 28 and may be updated, replaced, or obsoleted by other documents at any 29 time. It is inappropriate to use Internet-Drafts as reference 30 material or to cite them other than as "work in progress." 32 This Internet-Draft will expire on December 22, 2019. 34 Copyright Notice 36 Copyright (c) 2019 IETF Trust and the persons identified as the 37 document authors. All rights reserved. 39 This document is subject to BCP 78 and the IETF Trust's Legal 40 Provisions Relating to IETF Documents 41 (https://trustee.ietf.org/license-info) in effect on the date of 42 publication of this document. Please review these documents 43 carefully, as they describe your rights and restrictions with respect 44 to this document. Code Components extracted from this document must 45 include Simplified BSD License text as described in Section 4.e of 46 the Trust Legal Provisions and are provided without warranty as 47 described in the Simplified BSD License. 49 Table of Contents 51 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 52 1.1. Applicability . . . . . . . . . . . . . . . . . . . . . . 3 53 1.2. Assumptions and security properties . . . . . . . . . . . 3 54 1.3. Specification of Requirements . . . . . . . . . . . . . . 4 55 2. Conceptual overview of the protocol . . . . . . . . . . . . . 4 56 3. Data Structures . . . . . . . . . . . . . . . . . . . . . . . 6 57 3.1. The Interface Table . . . . . . . . . . . . . . . . . . . 6 58 3.2. The Neighbour table . . . . . . . . . . . . . . . . . . . 6 59 4. Protocol Operation . . . . . . . . . . . . . . . . . . . . . 7 60 4.1. HMAC computation . . . . . . . . . . . . . . . . . . . . 7 61 4.2. Packet Transmission . . . . . . . . . . . . . . . . . . . 8 62 4.3. Packet Reception . . . . . . . . . . . . . . . . . . . . 8 63 4.4. Expiring per-neighbour state . . . . . . . . . . . . . . 12 64 5. Packet Format . . . . . . . . . . . . . . . . . . . . . . . . 12 65 5.1. HMAC TLV . . . . . . . . . . . . . . . . . . . . . . . . 12 66 5.2. PC TLV . . . . . . . . . . . . . . . . . . . . . . . . . 13 67 5.3. Challenge Request TLV . . . . . . . . . . . . . . . . . . 13 68 5.4. Challenge Reply TLV . . . . . . . . . . . . . . . . . . . 14 69 6. Security Considerations . . . . . . . . . . . . . . . . . . . 14 70 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 15 71 8. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 16 72 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 16 73 9.1. Normative References . . . . . . . . . . . . . . . . . . 16 74 9.2. Informational References . . . . . . . . . . . . . . . . 17 75 Appendix A. Incremental deployment and key rotation . . . . . . 17 76 Appendix B. Changes from previous versions . . . . . . . . . . . 18 77 B.1. Changes since draft-ietf-babel-hmac-00 . . . . . . . . . 18 78 B.2. Changes since draft-ietf-babel-hmac-01 . . . . . . . . . 18 79 B.3. Changes since draft-ietf-babel-hmac-02 . . . . . . . . . 18 80 B.4. Changes since draft-ietf-babel-hmac-03 . . . . . . . . . 18 81 B.5. Changes since draft-ietf-babel-hmac-04 . . . . . . . . . 19 82 B.6. Changes since draft-ietf-babel-hmac-05 . . . . . . . . . 19 83 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 19 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); a node MUST NOT include multiple PC TLVs in a single 365 packet; 367 o for each key configured on the interface, an HMAC is computed as 368 specified in Section 4.1 above, and stored in an HMAC TLV that 369 MUST be appended to the packet trailer (see Section 4.2 of 370 [RFC6126bis]). 372 4.3. Packet Reception 374 When a packet is received on an interface that is configured for HMAC 375 protection, the following steps are performed before the packet is 376 passed to normal processing: 378 o First, the receiver checks whether the trailer of the received 379 packet carries at least one HMAC TLV; if not, the packet MUST be 380 immediately dropped and processing stops. Then, for each key 381 configured on the receiving interface, the receiver computes the 382 HMAC of the packet. It then compares every generated HMAC against 383 every HMAC included in the packet; if there is at least one match, 384 the packet passes the HMAC test; if there is none, the packet MUST 385 be silently dropped and processing stops at this point. In order 386 to avoid memory exhaustion attacks, an entry in the Neighbour 387 Table MUST NOT be created before the HMAC test has passed 388 successfully. The HMAC of the packet MUST NOT be computed for 389 each HMAC TLV contained in the packet, but only once for each 390 configured key. 392 o The packet body is then parsed a first time. During this 393 "preparse" phase, the packet body is traversed and all TLVs are 394 ignored except PC TLVs, Challenge Requests and Challenge Replies. 395 When a PC TLV is encountered, the enclosed PC and Index are saved 396 for later processing; if multiple PCs are found (which should not 397 happen, see Section 4.2 above), only the first one is processed, 398 the remaining ones MUST be silently ignored. If a Challenge 399 Request is encountered, a Challenge Reply MUST be scheduled, as 400 described in Section 4.3.1.2. If a Challenge Reply is 401 encountered, it is tested for validity as described in 402 Section 4.3.1.3 and a note is made of the result of the test. 404 o The preparse phase above has yielded two pieces of data: the PC 405 and Index from the first PC TLV, and a bit indicating whether the 406 packet contains a successful Challenge Reply. If the packet does 407 not contain a PC TLV, the packet MUST be dropped and processing 408 stops at this point. If the packet contains a successful 409 Challenge Reply, then the PC and Index contained in the PC TLV 410 MUST be stored in the Neighbour Table entry corresponding to the 411 sender (which may need to be created at this stage), and the 412 packet is accepted. 414 o Otherwise, if there is no entry in the Neighbour 415 Table corresponding to the sender, or if such an entry exists but 416 contains no Index, or if the Index it contains is different from 417 the Index contained in the PC TLV, then a challenge MUST be sent 418 as described in Section 4.3.1.1, the packet MUST be dropped, and 419 processing stops at this stage. 421 o At this stage, the packet contains no successful challenge reply 422 and the Index contained in the PC TLV is equal to the Index in the 423 Neighbour Table entry corresponding to the sender. The receiver 424 compares the received PC with the PC contained in the Neighbour 425 Table; if the received PC is smaller or equal than the PC 426 contained in the Neighbour Table, the packet MUST be dropped and 427 processing stops (no challenge is sent in this case, since the 428 mismatch might be caused by harmless packet reordering on the 429 link). Otherwise, the PC contained in the Neighbour Table entry 430 is set to the received PC, and the packet is accepted. 432 In the algorithm described above, challenge requests are processed 433 and challenges are sent before the PC/Index pair is verified against 434 the neighbour table. This simplifies the implementation somewhat 435 (the node may simply schedule outgoing requests as it walks the 436 packet during the preparse phase), but relies on the rate-limiting 437 described in Section 4.3.1.1 to avoid sending too many challenges in 438 response to replayed packets. As an optimisation, a node MAY ignore 439 all challenge requests contained in a packet except the last one, and 440 it MAY ignore a challenge request in the case where it it contained 441 in a packet with an Index that matches the one in the Neighbour 442 Table and a PC that is smaller or equal to the one contained in the 443 Neighbour Table. Since it is still possible to replay a packet with 444 an obsolete Index, the rate-limiting described in Section 4.3.1.1 is 445 required even if this optimisation is implemented. 447 The same is true of challenge replies. However, since validating a 448 challenge reply is extremely cheap (it's just a bitwise comparison of 449 two strings of octets), a similar optimisation for challenge replies 450 is not worthwile. 452 After the packet has been accepted, it is processed as normal, except 453 that any PC, Challenge Request and Challenge Reply TLVs that it 454 contains are silently ignored. 456 4.3.1. Challenge Requests and Replies 458 During the preparse stage, the receiver might encounter a mismatched 459 Index, to which it will react by scheduling a Challenge Request. It 460 might encounter a Challenge Request TLV, to which it will reply with 461 a Challenge Reply TLV. Finally, it might encounter a Challenge Reply 462 TLV, which it will attempt to match with a previously sent Challenge 463 Request TLV in order to update the Neighbour Table entry 464 corresponding to the sender of the packet. 466 4.3.1.1. Sending challenges 468 When it encounters a mismatched Index during the preparse phase, a 469 node picks a nonce that it has never used with any of the keys 470 currently configured on the relevant interface, for example by 471 drawing a sufficiently large random string of bytes or by consulting 472 a strictly monotonic hardware clock. It MUST then store the nonce in 473 the entry of the Neighbour Table associated to the neighbour (the 474 entry might need to be created at this stage), initialise the 475 neighbour's challenge expiry timer to 30 seconds, and send a 476 Challenge Request TLV to the unicast address corresponding to the 477 neighbour. 479 A node MAY aggregate a Challenge Request with other TLVs; in other 480 words, if it has already buffered TLVs to be sent to the unicast 481 address of the neighbour, it MAY send the buffered TLVs in the same 482 packet as the Challenge Request. However, it MUST arrange for the 483 Challenge Request to be sent in a timely manner, as any packets 484 received from that neighbour will be silently ignored until the 485 challenge completes. 487 Since a challenge may be prompted by a packet replayed by an 488 attacker, a node MUST impose a rate limitation to the challenges it 489 sends; the limit SHOULD default to one challenge request every 300ms, 490 and MAY be configurable. 492 4.3.1.2. Replying to challenges 494 When it encounters a Challenge Request during the preparse phase, a 495 node constructs a Challenge Reply TLV by copying the Nonce from the 496 Challenge Request into the Challenge Reply. It MUST then send the 497 Challenge Reply to the unicast address from which the Challenge 498 Request was sent. 500 A node MAY aggregate a Challenge Reply with other TLVs; in other 501 words, if it has already buffered TLVs to be sent to the unicast 502 address of the sender of the Challenge Request, it MAY send the 503 buffered TLVs in the same packet as the Challenge Reply. However, it 504 MUST arrange for the Challenge Reply to be sent in a timely manner 505 (within a few seconds), and SHOULD NOT send any other packets over 506 the same interface before sending the Challenge Reply, as those would 507 be dropped by the challenger. 509 A challenge sent to a multicast address MUST be silently ignored. 511 4.3.1.3. Receiving challenge replies 513 When it encounters a Challenge Reply during the preparse phase, a 514 node consults the Neighbour Table entry corresponding to the 515 neighbour that sent the Challenge Reply. If no challenge is in 516 progress, i.e., if there is no Nonce stored in the Neighbour 517 Table entry or the Challenge timer has expired, the Challenge Reply 518 MUST be silently ignored and the challenge has failed. 520 Otherwise, the node compares the Nonce contained in the Challenge 521 Reply with the Nonce contained in the Neighbour Table entry. If the 522 two are equal (they have the same length and content), then the 523 challenge has succeeded; otherwise, the challenge has failed. 525 4.4. Expiring per-neighbour state 527 The per-neighbour (Index, PC) pair is maintained in the neighbour 528 table, and is normally discarded when the neighbour table entry 529 expires. Implementations MUST ensure that an (Index, PC) pair is 530 discarded within a finite time since the last time a packet has been 531 accepted. In particular, unsuccessful challenges MUST NOT prevent an 532 (Index, PC) pair from being discarded for unbounded periods of time. 534 A possible implementation strategy for implementations that use a 535 Hello history (Appendix A of [RFC6126bis]) is to discard the (Index, 536 PC) pair whenever the Hello history becomes empty. Another 537 implementation strategy is to use a timer that is reset whenever a 538 packet is accepted, and to discard the (Index, PC) pair whenever the 539 timer expires. If the latter strategy is being used, the timer 540 SHOULD default to a value of 5 min, and MAY be configurable. 542 5. Packet Format 544 5.1. HMAC 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 = 16 | Length | HMAC... 550 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 552 Fields : 554 Type Set to 16 to indicate an HMAC TLV. 556 Length The length of the body, in octets, exclusive of the Type 557 and Length fields. The length of the body depends on the 558 HMAC algorithm being used. 560 HMAC The body contains the HMAC of the packet, computed as 561 described in Section 4.1. 563 This TLV is allowed in the packet trailer (see Section 4.2 of 564 [RFC6126bis]), and MUST be ignored if it is found in the packet body. 566 5.2. PC TLV 568 0 1 2 3 569 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 570 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 571 | Type = 17 | Length | PC | 572 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 573 | | Index... 574 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 576 Fields : 578 Type Set to 17 to indicate a PC TLV. 580 Length The length of the body, in octets, exclusive of the Type 581 and Length fields. 583 PC The Packet Counter (PC), a 32-bit (4 octet) unsigned 584 integer which is increased with every packet sent over this 585 interface. A fresh index (as defined in Section 3.1) MUST 586 be generated whenever the PC overflows. 588 Index The sender's Index, an opaque string of 0 to 32 octets. 590 Indices are limited to a size of 32 octets: a node MUST NOT send a 591 TLV with an index of size strictly larger than 32 octets, and a node 592 MAY ignore a PC TLV with an index of length strictly larger than 32 593 octets. Indices of length 0 are valid: if a node has reliable stable 594 storage and the packet counter never overflows, then only one index 595 is necessary, and the value of length 0 is the canonical choice. 597 5.3. Challenge Request TLV 599 0 1 2 3 600 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 601 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 602 | Type = 18 | Length | Nonce... 603 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 605 Fields : 607 Type Set to 18 to indicate a Challenge Request TLV. 609 Length The length of the body, in octets, exclusive of the Type 610 and Length fields. 612 Nonce The nonce uniquely identifying the challenge, an opaque 613 string of 0 to 192 octets. 615 Nonces are limited to a size of 192 octets: a node MUST NOT send a 616 Challenge Request TLV with a nonce of size strictly larger than 192 617 octets, and a node MAY ignore a nonce that is of size strictly larger 618 than 192 octets. Nonces of length 0 are valid: if a node has 619 reliable stable storage, then it may use a sequential counter for 620 generating nonces which get encoded in the minumum number of octets 621 required; the value 0 is then encoded as the string of length 0. 623 5.4. Challenge Reply TLV 625 0 1 2 3 626 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 627 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 628 | Type = 19 | Length | Nonce... 629 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 631 Fields : 633 Type Set to 19 to indicate a Challenge Reply TLV. 635 Length The length of the body, in octets, exclusive of the Type 636 and Length fields. 638 Nonce A copy of the nonce contained in the corresponding 639 challenge request. 641 6. Security Considerations 643 This document defines a mechanism that provides basic security 644 properties for the Babel routing protocol. The scope of this 645 protocol is strictly limited: it only provides authentication (we 646 assume that routing information is not confidential), it only 647 supports symmetric keying, and it only allows for the use of a small 648 number of symmetric keys on every link. Deployments that need more 649 features, e.g., confidentiality or asymmetric keying, should use a 650 more featureful security mechanism such as the one described in 651 [I-D.ietf-babel-dtls]. 653 This mechanism relies on two assumptions, as described in 654 Section 1.2. First, it assumes that the hash being used is 655 invulnerable to pre-image attacks (Section 1.1 of [RFC6039]); at the 656 time of writing, SHA-256, which is mandatory to implement 657 (Section 4.1), is believed to be safe against practical attacks. 659 Second, it assumes that indices and nonces are generated uniquely 660 over the lifetime of a key used for HMAC computation (more precisely, 661 indices must be unique for a given (key, source) pair, and nonces 662 must be unique for a given (key, source, destination) triple). This 663 property can be satisfied either by using a cryptographically secure 664 random number generator to generate indices and nonces that contain 665 enough entropy (64-bit values are believed to be large enough for all 666 practical applications), or by using a reliably monotonic hardware 667 clock. If uniqueness cannot be guaranteed (e.g., because a hardware 668 clock has been reset), then rekeying is necessary. 670 The expiry mechanism mandated in Section 4.4 is required to prevent 671 an attacker from delaying an authentic packet by an unbounded amount 672 of time. If an attacker is able to delay the delivery of a packet 673 (e.g., because it is located at a layer 2 switch), then the packet 674 will be accepted as long as the corresponding (Index, PC) pair is 675 present at the receiver. If the attacker is able to cause the 676 (Index, PC) pair to persist for arbitrary amounts of time (e.g., by 677 repeatedly causing failed challenges), then it is able to delay the 678 packet by arbitrary amounts of time, even after the sender has left 679 the network. 681 While it is probably not possible to be immune against denial of 682 service (DoS) attacks in general, this protocol includes a number of 683 mechanisms designed to mitigate such attacks. In particular, 684 reception of a packet with no correct HMAC creates no local state 685 whatsoever (Section 4.3). Reception of a replayed packet with 686 correct hash, on the other hand, causes a challenge to be sent; this 687 is mitigated somewhat by requiring that challenges be rate-limited. 689 At first sight, sending a challenge requires retaining enough 690 information to validate the challenge reply. However, the nonce 691 included in a challenge request and echoed in the challenge reply can 692 be fairly large (up to 192 octets), which should in principle permit 693 encoding the per-challenge state as a secure "cookie" within the 694 nonce itself. 696 7. IANA Considerations 698 IANA has allocated the following values in the Babel TLV Types 699 registry: 701 +------+-------------------+---------------+ 702 | Type | Name | Reference | 703 +------+-------------------+---------------+ 704 | 16 | HMAC | this document | 705 | | | | 706 | 17 | PC | this document | 707 | | | | 708 | 18 | Challenge Request | this document | 709 | | | | 710 | 19 | Challenge Reply | this document | 711 +------+-------------------+---------------+ 713 8. Acknowledgments 715 The protocol described in this document is based on the original HMAC 716 protocol defined by Denis Ovsienko [RFC7298]. The use of a pseudo- 717 header was suggested by David Schinazi. The use of an index to avoid 718 replay was suggested by Markus Stenberg. The authors are also 719 indebted to Donald Eastlake, Toke Hoiland-Jorgensen, Florian Horn, 720 Dave Taht and Martin Vigoureux. 722 9. References 724 9.1. Normative References 726 [RFC2104] Krawczyk, H., Bellare, M., and R. Canetti, "HMAC: Keyed- 727 Hashing for Message Authentication", RFC 2104, 728 DOI 10.17487/RFC2104, February 1997, 729 . 731 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 732 Requirement Levels", BCP 14, RFC 2119, 733 DOI 10.17487/RFC2119, March 1997. 735 [RFC6126bis] 736 Chroboczek, J. and D. Schinazi, "The Babel Routing 737 Protocol", draft-ietf-babel-rfc6126bis-06 (work in 738 progress), October 2018. 740 [RFC6234] Eastlake 3rd, D. and T. Hansen, "US Secure Hash Algorithms 741 (SHA and SHA-based HMAC and HKDF)", RFC 6234, 742 DOI 10.17487/RFC6234, May 2011, 743 . 745 [RFC7693] Saarinen, M-J., Ed. and J-P. Aumasson, "The BLAKE2 746 Cryptographic Hash and Message Authentication Code (MAC)", 747 RFC 7693, DOI 10.17487/RFC7693, November 2015, 748 . 750 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 751 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 752 May 2017. 754 9.2. Informational References 756 [I-D.ietf-babel-dtls] 757 Decimo, A., Schinazi, D., and J. Chroboczek, "Babel 758 Routing Protocol over Datagram Transport Layer Security", 759 draft-ietf-babel-dtls-01 (work in progress), October 2018. 761 [RFC4086] Eastlake 3rd, D., Schiller, J., and S. Crocker, 762 "Randomness Requirements for Security", BCP 106, RFC 4086, 763 DOI 10.17487/RFC4086, June 2005, 764 . 766 [RFC6039] Manral, V., Bhatia, M., Jaeggli, J., and R. White, "Issues 767 with Existing Cryptographic Protection Methods for Routing 768 Protocols", RFC 6039, DOI 10.17487/RFC6039, October 2010, 769 . 771 [RFC7298] Ovsienko, D., "Babel Hashed Message Authentication Code 772 (HMAC) Cryptographic Authentication", RFC 7298, 773 DOI 10.17487/RFC7298, July 2014, 774 . 776 Appendix A. Incremental deployment and key rotation 778 This protocol supports incremental deployment (transitioning from an 779 insecure network to a secured network with no service interruption) 780 and key rotation (transitioning from a set of keys to a different set 781 of keys). 783 In order to perform incremental deployment, the nodes in the network 784 are first configured in a mode where packets are sent with 785 authentication but not checked on reception. Once all the nodes in 786 the network are configured to send authenticated packets, nodes are 787 reconfigured to reject unauthenticated packets. 789 In order to perform key rotation, the new key is added to all the 790 nodes; once this is done, both the old and the new key are sent in 791 all packets, and packets are accepted if they are properly signed by 792 either of the keys. At that point, the old key is removed. 794 In order to support incremental deployment and key rotation, 795 implementations SHOULD support an interface configuration in which 796 they send authenticated packets but accept all packets, and SHOULD 797 allow changing the set of keys associated with an interface without a 798 restart. 800 Appendix B. Changes from previous versions 802 [RFC Editor: please remove this section before publication.] 804 B.1. Changes since draft-ietf-babel-hmac-00 806 o Changed the title. 808 o Removed the appendix about the packet trailer, this is now in 809 rfc6126bis. 811 o Removed the appendix with implicit indices. 813 o Clarified the definitions of acronyms. 815 o Limited the size of nonces and indices. 817 B.2. Changes since draft-ietf-babel-hmac-01 819 o Made BLAKE2s a recommended HMAC algorithm. 821 o Added requirement to expire per-neighbour crypto state. 823 B.3. Changes since draft-ietf-babel-hmac-02 825 o Clarified that PCs are 32-bit unsigned integers. 827 o Clarified that indices and nonces are of arbitrary size. 829 o Added reference to RFC 4086. 831 B.4. Changes since draft-ietf-babel-hmac-03 833 o Use the TLV values allocated by IANA. 835 o Fixed an issue with packets that contain a successful challenge 836 reply: they should be accepted before checking the PC value. 838 o Clarified that keys are the exact value of the HMAC hash size, and 839 not subject to preprocessing; this makes management more 840 deterministic. 842 B.5. Changes since draft-ietf-babel-hmac-04 844 o Use normative language in more places. 846 B.6. Changes since draft-ietf-babel-hmac-05 848 o Do not update RFC 6126bis. 850 o Clarify that indices and nonces of length 0 are valid. 852 o Clarify that multiple PC TLVs in a single packet are not allowed. 854 o Allow discarding challenge requests when they carry an old PC. 856 Authors' Addresses 858 Clara Do 859 IRIF, University of Paris-Diderot 860 75205 Paris Cedex 13 861 France 863 Email: clarado_perso@yahoo.fr 865 Weronika Kolodziejak 866 IRIF, University of Paris-Diderot 867 75205 Paris Cedex 13 868 France 870 Email: weronika.kolodziejak@gmail.com 872 Juliusz Chroboczek 873 IRIF, University of Paris-Diderot 874 Case 7014 875 75205 Paris Cedex 13 876 France 878 Email: jch@irif.fr