idnits 2.17.00 (12 Aug 2021) /tmp/idnits54720/draft-ietf-ipsecme-dh-checks-04.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 : ---------------------------------------------------------------------------- == There are 1 instance of lines with non-RFC6890-compliant IPv4 addresses in the document. If these are example addresses, they should be changed. -- The draft header indicates that this document updates RFC5996, but the abstract doesn't seem to directly say this. It does mention RFC5996 though, so this could be OK. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year (Using the creation date from RFC5996, updated by this document, for RFC5378 checks: 2008-08-26) -- The document seems to lack a disclaimer for pre-RFC5378 work, but may have content which was first submitted before 10 November 2008. If you have contacted all the original authors and they are all willing to grant the BCP78 rights to the IETF Trust, then this is fine, and you can ignore this comment. If not, you may need to add the pre-RFC5378 disclaimer. (See the Legal Provisions document at https://trustee.ietf.org/license-info for more information.) -- The document date (May 4, 2013) is 3304 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) ** Obsolete normative reference: RFC 5996 (Obsoleted by RFC 7296) == Outdated reference: draft-merkle-ikev2-ke-brainpool has been published as RFC 6954 Summary: 1 error (**), 0 flaws (~~), 3 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 ipsecme Y. Sheffer 3 Internet-Draft Porticor 4 Updates: 5996 (if approved) S. Fluhrer 5 Intended status: Standards Track Cisco 6 Expires: November 5, 2013 May 4, 2013 8 Additional Diffie-Hellman Tests for IKEv2 9 draft-ietf-ipsecme-dh-checks-04 11 Abstract 13 This document adds a small number of mandatory tests required for the 14 secure operation of IKEv2 with elliptic curve groups. No change is 15 required to IKE implementations that use modular exponential groups, 16 other than a few rarely used so-called DSA groups. This document 17 updates the IKEv2 protocol, RFC 5996. 19 Status of this Memo 21 This Internet-Draft is submitted in full conformance with the 22 provisions of BCP 78 and BCP 79. 24 Internet-Drafts are working documents of the Internet Engineering 25 Task Force (IETF). Note that other groups may also distribute 26 working documents as Internet-Drafts. The list of current Internet- 27 Drafts is at http://datatracker.ietf.org/drafts/current/. 29 Internet-Drafts are draft documents valid for a maximum of six months 30 and may be updated, replaced, or obsoleted by other documents at any 31 time. It is inappropriate to use Internet-Drafts as reference 32 material or to cite them other than as "work in progress." 34 This Internet-Draft will expire on November 5, 2013. 36 Copyright Notice 38 Copyright (c) 2013 IETF Trust and the persons identified as the 39 document authors. All rights reserved. 41 This document is subject to BCP 78 and the IETF Trust's Legal 42 Provisions Relating to IETF Documents 43 (http://trustee.ietf.org/license-info) in effect on the date of 44 publication of this document. Please review these documents 45 carefully, as they describe your rights and restrictions with respect 46 to this document. Code Components extracted from this document must 47 include Simplified BSD License text as described in Section 4.e of 48 the Trust Legal Provisions and are provided without warranty as 49 described in the Simplified BSD License. 51 Table of Contents 53 1. Introduction . . . . . . . . . . . . . . . . . . . . . 3 54 1.1. Conventions used in this document . . . . . . . . . . 3 55 2. Group Membership Tests . . . . . . . . . . . . . . . . 3 56 2.1. Sophie Germain Prime MODP Groups . . . . . . . . . . . 3 57 2.2. MODP Groups with Small Subgroups . . . . . . . . . . . 4 58 2.3. Elliptic Curve Groups . . . . . . . . . . . . . . . . 4 59 2.4. Transition . . . . . . . . . . . . . . . . . . . . . . 5 60 2.5. Protocol Behavior . . . . . . . . . . . . . . . . . . 5 61 3. Side-Channel Attacks . . . . . . . . . . . . . . . . . 6 62 4. Security Considerations . . . . . . . . . . . . . . . 6 63 4.1. DH Key Reuse and Multiple Peers . . . . . . . . . . . 6 64 4.2. DH Key Reuse: Variants . . . . . . . . . . . . . . . . 7 65 4.3. Groups not covered by this RFC . . . . . . . . . . . . 7 66 4.4. Behavior Upon Test Failure . . . . . . . . . . . . . . 7 67 5. IANA Considerations . . . . . . . . . . . . . . . . . 8 68 6. Acknowledgements . . . . . . . . . . . . . . . . . . . 8 69 7. References . . . . . . . . . . . . . . . . . . . . . . 9 70 7.1. Normative References . . . . . . . . . . . . . . . . . 9 71 7.2. Informative References . . . . . . . . . . . . . . . . 9 72 Appendix A. Appendix: Change Log . . . . . . . . . . . . . . . . . 10 73 A.1. -04 . . . . . . . . . . . . . . . . . . . . . . . . . 10 74 A.2. -03 . . . . . . . . . . . . . . . . . . . . . . . . . 10 75 A.3. -02 . . . . . . . . . . . . . . . . . . . . . . . . . 10 76 A.4. -01 . . . . . . . . . . . . . . . . . . . . . . . . . 10 77 A.5. -00 . . . . . . . . . . . . . . . . . . . . . . . . . 10 78 Authors' Addresses . . . . . . . . . . . . . . . . . . 10 80 1. Introduction 82 IKEv2 [RFC5996] consists of the establishment of a shared secret 83 using the Diffie-Hellman (DH) protocol, followed by authentication of 84 the two peers. Existing implementations typically use modular 85 exponential (MODP) DH groups, such as those defined in [RFC3526]. 87 IKEv2 does not require that any tests be performed by a peer 88 receiving a public Diffie-Hellman key from the other peer. This is 89 fine for the common case of MODP groups. For other DH groups, when 90 peers reuse DH values across multiple IKE sessions, the lack of tests 91 by the recipient results in a potential vulnerability (see 92 Section 4.1 for more details). In particular, this is true for 93 Elliptic Curve (EC) groups whose use is becoming ever more popular. 94 This document defines such tests for several types of DH groups. 96 In addition, this document describes another potential attack related 97 to reuse of DH keys: a timing attack. This additional material is 98 taken from [RFC2412]. 100 This document updates [RFC5996] by adding security requirements that 101 apply to many of the protocol's implementations. 103 1.1. Conventions used in this document 105 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 106 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 107 document are to be interpreted as described in [RFC2119]. 109 2. Group Membership Tests 111 This section describes the tests that need to be performed by IKE 112 peers receiving a Key Exchange (KE) payload. The tests are 113 RECOMMENDED for all implementations, but only REQUIRED for those that 114 reuse DH secret keys (as defined in [RFC5996], Sec. 2.12). The tests 115 apply to the recipient of a KE payload, and describe how it should 116 check the received payload. They are listed here according to the DH 117 group being used. 119 2.1. Sophie Germain Prime MODP Groups 121 These are currently the most commonly used groups; all these groups 122 have the property that (p-1)/2 is also prime; this section applies to 123 any such MODP group. Each recipient MUST verify that the peer's 124 public value r is in the legal range (1 < r < p-1). According to 125 [Menezes], Sec 2.2, even with this check there remains the 126 possibility of leaking a single bit of the secret exponent when DH 127 keys are reused; this amount of leakage is insignificant. 129 See Section 5 for the specific groups covered by this section. 131 2.2. MODP Groups with Small Subgroups 133 [RFC5114] defines modular exponential groups with small subgroups; 134 these are modular exponential groups with comparatively small 135 subgroups, and all have (p-1)/2 composite. Sec. 2.1 of [Menezes] 136 describes some informational leakage from a small subgroup attack on 137 these groups, if the DH private value is reused. 139 This leakage can be prevented if the recipient performs a test on the 140 peer's public value, however this test is expensive (approximately as 141 expensive as what reusing DH private values saves). In addition, the 142 NIST standard [NIST-800-56A] requires that test (see section 143 5.6.2.4), hence anyone needing to conform to that standard will need 144 to implement the test anyway. 146 Because of the above, the IKE implementation MUST choose between one 147 of the following two options: 149 o It MUST check both that the peer's public value is in range (1 < r 150 < p-1) and that r^q = 1 mod p (where q is the size of the 151 subgroup, as listed in the RFC). DH private values MAY then be 152 reused. This option is appropriate if conformance to 153 [NIST-800-56A] is required. 154 o It MUST NOT reuse DH private values (that is, the DH private value 155 for each DH exchange MUST be generated from a fresh output of a 156 cryptographically secure random number generator), and it MUST 157 check that the peer's public value is in range (1 < r < p-1). 158 This option is more appropriate if conformance to [NIST-800-56A] 159 is not required. 161 See Section 5 for the specific groups covered by this section. 163 2.3. Elliptic Curve Groups 165 IKEv2 can be used with elliptic curve groups defined over a field 166 GF(p) [RFC5903] [RFC5114]. According to [Menezes], Sec. 2.3, there 167 is some informational leakage possible. A receiving peer MUST check 168 that its peer's public value is valid; that is, the x and y 169 parameters from the peer's public value satisfy the curve equation, 170 y^2 = x^3 + ax + b mod p (where for groups 19, 20, 21, a=-3 (mod p), 171 and all other values of a, b and p for the group are listed in the 172 RFC). 174 We note that an additional check to ensure that the public value is 175 not the point at infinity is not needed, because IKE (in Sec. 7 of 176 [RFC5903]) does not allow for encoding this value. 178 See Section 5 for the specific groups covered by this section. 180 2.4. Transition 182 Existing implementations of IKEv2 with ECDH groups MAY be modified to 183 include the tests described in the current document, even if they do 184 not reuse DH keys. The tests can be considered as sanity checks, and 185 will prevent the code having to handle inputs that it may not have 186 been designed to handle. 188 ECDH implementations that do reuse DH keys MUST be enhanced to 189 include the above tests. 191 2.5. Protocol Behavior 193 The recipient of a DH public key that fails one of the above tests 194 can assume that the sender is either truly malicious or else it has a 195 bug in its implementation. 197 If this error happens during the IKE_SA_INIT exchange, then the 198 recipient MUST drop the message that contains an invalid KE payload, 199 and MUST NOT use that message when creating the IKE SA. 201 If the implementation implements the DoS-resistant behavior proposed 202 in Sec. 2.4 of [RFC5996], it may simply ignore the erroneous request 203 or response message, and continue waiting for a later message 204 containing a legitimate KE payload. 206 If DoS-resistant behavior is not implemented, and the invalid KE 207 payload was in the IKE_SA_INIT request, the implementation MAY send 208 an INVALID_SYNTAX error notification back, and remove the in-progress 209 IKE SA; if the invalid KE payload was in the IKE_SA_INIT response, 210 then the implementation MAY simply delete the half created IKE SA, 211 and re-initiate the exchange. 213 If the invalid KE payload is received during the CREATE_CHILD_SA 214 exchange (or any other exchange after the IKE SA has been 215 established) and the invalid KE payload is in the request message, 216 the Responder MUST reply with an INVALID_SYNTAX error notification 217 and drop the IKE SA. If the invalid KE payload is in a response, the 218 Initiator getting this reply MUST immediately delete the IKE SA by 219 sending an IKE SA Delete notification as a new exchange. In this 220 case the sender evidently has an implementation bug, and dropping the 221 IKE SA makes it easier to detect. 223 3. Side-Channel Attacks 225 In addition to the small-subgroup attack, there is also a potential 226 timing attack on IKE peers when they are reusing Diffie-Hellman 227 secret values. This is a side-channel attack, which means that it 228 may or may not be a vulnerability in certain cases, depending on 229 implementation details and the threat model. 231 The remainder of this section is quoted from [RFC2412], Sec. 5, with 232 a few minor clarifications. This attack still applies to IKEv2 233 implementations, and both to MODP groups and ECDH groups. We also 234 note that more efficient countermeasures are available for EC groups 235 represented in projective form, but these are outside the scope of 236 the current document. 238 Timing attacks that are capable of recovering the exponent value used 239 in Diffie-Hellman calculations have been described by Paul Kocher 240 [Kocher]. In order to nullify the attack, implementors must take 241 pains to obscure the sequence of operations involved in carrying out 242 modular exponentiations. 244 One potential method to foil these timing attacks is to use a 245 "blinding factor". In this method, a group element, r, is chosen at 246 random, and its multiplicative inverse modulo p is computed, which 247 we'll call r_inv. r_inv can be computed by the Extended Euclidean 248 Method, using r and p as inputs. When an exponent x is chosen, the 249 value r_inv^x is also calculated. Then, when calculating (g^y)^x, 250 the implementation will calculate this sequence: 252 A = r*g^y 253 B = A^x = (r*g^y)^x = (r^x)(g^(xy)) 254 C = B*r_inv^x = (r^x)(r^(-1*x))(g^(xy)) = g^(xy) 256 The blinding factor is only necessary if the exponent x is used more 257 than 100 times (estimate by Richard Schroeppel). 259 4. Security Considerations 261 This entire document is concerned with the IKEv2 security protocol 262 and the need to harden it in some cases. 264 4.1. DH Key Reuse and Multiple Peers 266 This section describes one variant of the attack prevented by the 267 tests defined above. 269 Suppose that IKE peer Alice maintains IKE security associations with 270 peers Bob and Eve. Alice uses the same secret ECDH key for both SAs, 271 which is allowed with some restrictions. If Alice does not implement 272 these tests, Eve will be able to send a malformed public key, which 273 would allow her to efficiently determine Alice's secret key (as 274 described in Sec. 2 of [Menezes]). Since the key is shared, Eve will 275 be able to obtain Alice's shared IKE SA key with Bob. 277 4.2. DH Key Reuse: Variants 279 Private DH keys can be reused in different ways, with subtly 280 different security implications. For example: 282 1. DH keys are reused for multiple connections (IKE SAs) to the same 283 peer, and for connections to different peers. 284 2. DH keys are reused for multiple connections to the same peer 285 (e.g. when the peer is identified by its IP address) but not for 286 different peers. 287 3. DH keys are reused only when they had not been used to complete 288 an exchange, e.g. when the peer replies with an 289 INVALID_KE_PAYLOAD notification. 291 Both the small subgroup attack and the timing attack described in 292 this document apply at least to options #1 and #2. 294 4.3. Groups not covered by this RFC 296 There are a number of group types that are not specifically addressed 297 by this RFC. A document that defines such a group MUST describe the 298 tests required by that group. 300 One specific type of group would be an even-characteristic elliptic 301 curve group. Now, these curves have cofactors greater than 1; this 302 leads to a possibility of some information leakage. There are 303 several ways to address this information leakage, such as performing 304 a test analogous to the test in section 2.2, or adjusting the ECDH 305 operation to avoid this leakage (such as "ECC CDH", where the shared 306 secret really is hxyG). Because the appropriate test depends on how 307 the group is defined, we cannot document it in advance. 309 4.4. Behavior Upon Test Failure 311 The behavior recommended in Section 2.5 is in line with generic error 312 treatment during the IKE_SA_INIT exchange, Sec. 2.21.1 of [RFC5996]. 313 The sender is not required to send back an error notification, and 314 the recipient cannot depend on this notification because it is 315 unauthenticated, and may in fact have been sent by an attacker trying 316 to DoS the connection. Thus, the notification is only useful to 317 debug implementation errors. 319 On the other hand, the error notification is secure, in the sense 320 that no secret information is leaked. All IKEv2 Diffie-Hellman 321 groups are publicly known, and none of the tests defined here depend 322 on any secret key. In fact the tests can all be performed by an 323 eavesdropper. 325 The situation when the failure occurs in the Create Child SA exchange 326 is different, since everything is protected by an IKE SA. The peers 327 are authenticated, and error notifications can be relied on. See 328 Sec. 2.21.3 of [RFC5996] for more details on error handling in this 329 case. 331 5. IANA Considerations 333 This document requests that IANA should add a column named "Recipient 334 Tests" to the IKEv2 DH Group Transform IDs Registry 335 [IANA-DH-Registry]. 337 This column should initially be populated as per the following table. 339 +------------------------------------+---------------------+ 340 | Number | Recipient Tests | 341 +------------------------------------+---------------------+ 342 | 1, 2, 5, 14, 15, 16, 17, 18 | [current], Sec. 2.1 | 343 | 22, 23, 24 | [current], Sec. 2.2 | 344 | 19, 20, 21, 25, 26, 27, 28, 29, 30 | [current], Sec. 2.3 | 345 +------------------------------------+---------------------+ 347 Note to RFC Editor: please replace [current] by the RFC number 348 assigned to this document. 350 Groups 27-30 have been recently defined in 351 [I-D.merkle-ikev2-ke-brainpool]. 353 Future documents that define new DH groups for IKEv2 are REQUIRED to 354 provide this information for each new group, possibly by referring to 355 the current document. 357 6. Acknowledgements 359 We would like to thank Dan Harkins who initially raised this issue on 360 the ipsec mailing list. Thanks to Tero Kivinen and Rene Struik for 361 their useful comments. Much of the text in Section 3 is taken from 362 [RFC2412] and we would like to thank its author, Hilarie Orman. 364 The document was prepared using the lyx2rfc tool, created by Nico 365 Williams. 367 7. References 369 7.1. Normative References 371 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 372 Requirement Levels", BCP 14, RFC 2119, March 1997. 374 [RFC5996] Kaufman, C., Hoffman, P., Nir, Y., and P. Eronen, 375 "Internet Key Exchange Protocol Version 2 (IKEv2)", 376 RFC 5996, September 2010. 378 7.2. Informative References 380 [RFC2412] Orman, H., "The OAKLEY Key Determination Protocol", 381 RFC 2412, November 1998. 383 [RFC3526] Kivinen, T. and M. Kojo, "More Modular Exponential (MODP) 384 Diffie-Hellman groups for Internet Key Exchange (IKE)", 385 RFC 3526, May 2003. 387 [RFC5114] Lepinski, M. and S. Kent, "Additional Diffie-Hellman 388 Groups for Use with IETF Standards", RFC 5114, 389 January 2008. 391 [RFC5903] Fu, D. and J. Solinas, "Elliptic Curve Groups modulo a 392 Prime (ECP Groups) for IKE and IKEv2", RFC 5903, 393 June 2010. 395 [I-D.merkle-ikev2-ke-brainpool] 396 Merkle, J. and M. Lochter, "Using the ECC Brainpool Curves 397 for IKEv2 Key Exchange", 398 draft-merkle-ikev2-ke-brainpool-06 (work in progress), 399 April 2013. 401 [NIST-800-56A] 402 National Institute of Standards and Technology (NIST), 403 "Recommendation for Pair-Wise Key Establishment Schemes 404 Using Discrete Logarithm Cryptography (Revised)", NIST PUB 405 800-56A, March 2007. 407 [Kocher] Kocher, P., "Timing Attacks on Implementations of Diffie- 408 Hellman, RSA, DSS, and Other Systems", December 1996, 409 . 411 [Menezes] Menezes, A. and B. Ustaoglu, "On Reusing Ephemeral Keys In 412 Diffie-Hellman Key Agreement Protocols", December 2008, . 416 [IANA-DH-Registry] 417 IANA, "Internet Key Exchange Version 2 (IKEv2) Parameters, 418 Transform Type 4 - Diffie-Hellman Group Transform IDs", 419 Jan. 2005, . 422 Appendix A. Appendix: Change Log 424 Note to RFC Editor: please remove this section before publication. 426 A.1. -04 428 o Implemented Sean's AD review, and removed the inapplicable 429 requirement on the point at infinity. 431 A.2. -03 433 o Added the Brainpool curves to the IANA registration table. 435 A.3. -02 437 o Based on Tero's review: Improved the protocol behavior, and 438 mentioned that these checks apply to Create Child SA. Added a 439 discussion of DH timing attacks, stolen from RFC 2412. 441 A.4. -01 443 o Corrected an author's name that was misspelled. 444 o Added recipient behavior if a test fails, and the related security 445 considerations. 447 A.5. -00 449 o First WG document. 450 o Clarified IANA actions. 451 o Discussion of potential future groups not covered here. 452 o Clarification re: practicality of recipient tests for DSA groups. 454 Authors' Addresses 456 Yaron Sheffer 457 Porticor 458 10 Yirmiyahu St. 459 Ramat HaSharon 47298 460 Israel 462 Email: yaronf.ietf@gmail.com 464 Scott Fluhrer 465 Cisco Systems 466 1414 Massachusetts Ave. 467 Boxborough, MA 01719 468 USA 470 Email: sfluhrer@cisco.com