idnits 2.17.1 draft-ietf-ipsecme-dh-checks-03.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 (April 22, 2013) is 4019 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: A later version (-06) exists of draft-merkle-ikev2-ke-brainpool-04 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: October 24, 2013 April 22, 2013 8 Additional Diffie-Hellman Tests for IKEv2 9 draft-ietf-ipsecme-dh-checks-03 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 October 24, 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 . . . . . . . . . . . . . . . . . 5 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. -03 . . . . . . . . . . . . . . . . . . . . . . . . . 10 74 A.2. -02 . . . . . . . . . . . . . . . . . . . . . . . . . 10 75 A.3. -01 . . . . . . . . . . . . . . . . . . . . . . . . . 10 76 A.4. -00 . . . . . . . . . . . . . . . . . . . . . . . . . 10 77 Authors' Addresses . . . . . . . . . . . . . . . . . . 10 79 1. Introduction 81 IKEv2 [RFC5996] consists of the establishment of a shared secret 82 using the Diffie-Hellman (DH) protocol, followed by authentication of 83 the two peers. Existing implementations typically use modular 84 exponential (MODP) DH groups, such as those defined in [RFC3526]. 86 IKEv2 does not require that any tests be performed by a peer 87 receiving a public Diffie-Hellman key from the other peer. This is 88 fine for the common case of MODP groups. For other DH groups, when 89 peers reuse DH values across multiple IKE sessions, the lack of tests 90 by the recipient results in a potential vulnerability (see 91 Section 4.1 for more details). In particular, this is true for 92 elliptic curve groups whose use is becoming ever more popular. This 93 document defines such tests for several types of DH groups. 95 In addition, this document describes another potential attack related 96 to reuse of DH keys: a timing attack. This additional material is 97 taken from [RFC2412]. 99 1.1. Conventions used in this document 101 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 102 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 103 document are to be interpreted as described in [RFC2119]. 105 2. Group Membership Tests 107 This section describes the tests that need to be performed by IKE 108 peers receiving a Key Exchange (KE) payload. The tests are 109 RECOMMENDED for all implementations, but only REQUIRED for those that 110 reuse DH secret keys (as defined in [RFC5996], Sec. 2.12). The tests 111 apply to the recipient of a KE payload, and describe how it should 112 check the received payload. They are listed here according to the DH 113 group being used. 115 2.1. Sophie Germain Prime MODP Groups 117 These are currently the most commonly used groups; all these groups 118 have the property that (p-1)/2 is also prime; this section applies to 119 any such MODP group. Each recipient MUST verify that the peer's 120 public value r is in the legal range (1 < r < p-1). According to 121 [Menezes], Sec 2.2, even with this check there remains the 122 possibility of leaking a single bit of the secret exponent when DH 123 keys are reused; this amount of leakage is insignificant. 125 See Section 5 for the specific groups covered by this section. 127 2.2. MODP Groups with Small Subgroups 129 [RFC5114] defines modular exponential groups with small subgroups; 130 these are modular exponential groups with comparatively small 131 subgroups, and all have (p-1)/2 composite. Sec. 2.1 of [Menezes] 132 describes some informational leakage from a small subgroup attack on 133 these groups, if the DH private value is reused. 135 This leakage can be prevented if the recipient performs a test on the 136 peer's public value, however this test is expensive (approximately as 137 expensive as what reusing DH private values saves). In addition, the 138 NIST standard [NIST-800-56A] requires that test (see section 139 5.6.2.4), hence anyone needing to conform to that standard will need 140 to implement the test anyway. 142 Because of the above, the IKE implementation MUST choose between one 143 of the following two options: 145 o It MUST check both that the peer's public value is in range (1 < r 146 < p-1) and that r**q = 1 mod p (where q is the size of the 147 subgroup, as listed in the RFC). DH private values MAY then be 148 reused. This option is appropriate if conformance to 149 [NIST-800-56A] is required. 150 o It MUST NOT reuse DH private values (that is, the DH private value 151 for each DH exchange MUST be generated from a fresh output of a 152 cryptographically secure random number generator), and it MUST 153 check that the peer's public value is in range (1 < r < p-1). 154 This option is more appropriate if conformance to [NIST-800-56A] 155 is not required. 157 See Section 5 for the specific groups covered by this section. 159 2.3. Elliptic Curve Groups 161 IKEv2 can be used with elliptic curve groups defined over a field 162 GF(p) [RFC5903] [RFC5114]. According to [Menezes], Sec. 2.3, there 163 is some informational leakage possible. A receiving peer MUST check 164 that its peer's public value is valid; that is, it is not the point- 165 at-infinity, and that the x and y parameters from the peer's public 166 value satisfy the curve equation, that is, y**2 = x**3 + ax + b mod p 167 (where for groups 19, 20, 21, a=-3 (mod p), and all other values of 168 a, b and p for the group are listed in the RFC). 170 See Section 5 for the specific groups covered by this section. 172 2.4. Transition 174 Existing implementations of IKEv2 with ECDH groups MAY be modified to 175 include the tests described in the current document, even if they do 176 not reuse DH keys. The tests can be considered as sanity checks, and 177 will prevent the code having to handle inputs that it may not have 178 been designed to handle. 180 ECDH implementations that do reuse DH keys MUST be enhanced to 181 include the above tests. 183 2.5. Protocol Behavior 185 The recipient of a DH public key that fails one of the above tests 186 can assume that the sender is either truly malicious or else it has a 187 bug in its implementation. 189 If this error happens during the IKE_SA_INIT exchange, then the 190 recipient MUST drop the message that contains an invalid KE payload, 191 and MUST NOT use that message when creating the IKE SA. 193 If the implementation implements the DoS-resistant behavior proposed 194 in Sec. 2.4 of [RFC5996], it may simply ignore the erroneous request 195 or response message, and continue waiting for a later message 196 containing a legitimate KE payload. 198 If DoS-resistant behavior is not implemented, and the invalid KE 199 payload was in the IKE_SA_INIT request, the implementation MAY send 200 an INVALID_SYNTAX error notification back, and remove the in-progress 201 IKE SA; if the invalid KE payload was in the IKE_SA_INIT response, 202 then the implementation MAY simply delete the half created IKE SA, 203 and re-initiate the exchange. 205 If the invalid KE payload is received during the CREATE_CHILD_SA 206 exchange (or any other exchange after the IKE SA has been 207 established) and the invalid KE payload is in the request message, 208 the Responder MUST reply with an INVALID_SYNTAX error notification 209 and drop the IKE SA. If the invalid KE payload is in a response, the 210 Initiator getting this reply MUST immediately delete the IKE SA by 211 sending an IKE SA Delete notification as a new exchange. In this 212 case the sender evidently has an implementation bug, and dropping the 213 IKE SA makes it easier to detect. 215 3. Side-Channel Attacks 217 In addition to the small-subgroup attack, there is also a potential 218 timing attack on IKE peers when they are reusing Diffie-Hellman 219 secret values. This is a side-channel attack, which means that it 220 may or may not be a vulnerability in certain cases, depending on 221 implementation details and the threat model. 223 The remainder of this section is quoted from [RFC2412], Sec. 5, with 224 a few minor clarifications. This attack still applies to IKEv2 225 implementations, and both to MODP groups and ECDH groups. We also 226 note that more efficient countermeasures are available for ECC groups 227 represented in projective form, but these are outside the scope of 228 the current document. 230 Timing attacks that are capable of recovering the exponent value used 231 in Diffie-Hellman calculations have been described by Paul Kocher 232 [Kocher]. In order to nullify the attack, implementors must take 233 pains to obscure the sequence of operations involved in carrying out 234 modular exponentiations. 236 One potential method to foil these timing attacks is to use a 237 "blinding factor". In this method, a group element, r, is chosen at 238 random, and its multiplicative inverse modulo p is computed, which 239 we'll call r_inv. r_inv can be computed by the Extended Euclidean 240 Method, using r and p as inputs. When an exponent x is chosen, the 241 value r_inv^x is also calculated. Then, when calculating (g^y)^x, 242 the implementation will calculate this sequence: 244 A = r*g^y 245 B = A^x = (r*g^y)^x = (r^x)(g^(xy)) 246 C = B*r_inv^x = (r^x)(r^(-1*x))(g^(xy)) = g^(xy) 248 The blinding factor is only necessary if the exponent x is used more 249 than 100 times (estimate by Richard Schroeppel). 251 4. Security Considerations 253 This entire document is concerned with the IKEv2 security protocol 254 and the need to harden it in some cases. 256 4.1. DH Key Reuse and Multiple Peers 258 This section describes one variant of the attack prevented by the 259 tests defined above. 261 Suppose that IKE peer Alice maintains IKE security associations with 262 peers Bob and Eve. Alice uses the same secret ECDH key for both SAs, 263 which is allowed with some restrictions. If Alice does not implement 264 these tests, Eve will be able to send a malformed public key, which 265 would allow her to efficiently determine Alice's secret key (as 266 described in Sec. 2 of [Menezes]). Since the key is shared, Eve will 267 be able to obtain Alice's shared IKE SA key with Bob. 269 4.2. DH Key Reuse: Variants 271 Private DH keys can be reused in different ways, with subtly 272 different security implications. For example: 274 1. DH keys are reused for multiple connections (IKE SAs) to the same 275 peer, and for connections to different peers. 276 2. DH keys are reused for multiple connections to the same peer 277 (e.g. when the peer is identified by its IP address) but not for 278 different peers. 279 3. DH keys are reused only when they had not been used to complete 280 an exchange, e.g. when the peer replies with an 281 INVALID_KE_PAYLOAD notification. 283 Both the small subgroup attack and the timing attack described in 284 this document apply at least to options #1 and #2. 286 4.3. Groups not covered by this RFC 288 There are a number of group types that are not specifically addressed 289 by this RFC. A document that defines such a group MUST describe the 290 tests required by that group. 292 One specific type of group would be an even-characteristic elliptic 293 curve group. Now, these curves have cofactors greater than 1; this 294 leads to a possibility of some information leakage. There are 295 several ways to address this information leakage, such as performing 296 a test analogous to the test in section 2.2, or adjusting the ECDH 297 operation to avoid this leakage (such as "ECC CDH", where the shared 298 secret really is hxyG). Because the appropriate test depends on how 299 the group is defined, we cannot document it in advance. 301 4.4. Behavior Upon Test Failure 303 The behavior recommended in Section 2.5 is in line with generic error 304 treatment during the IKE_SA_INIT exchange, Sec. 2.21.1 of [RFC5996]. 305 The sender is not required to send back an error notification, and 306 the recipient cannot depend on this notification because it is 307 unauthenticated, and may in fact have been sent by an attacker trying 308 to DoS the connection. Thus, the notification is only useful to 309 debug implementation errors. 311 On the other hand, the error notification is secure, in the sense 312 that no secret information is leaked. All IKEv2 Diffie-Hellman 313 groups are publicly known, and none of the tests defined here depend 314 on any secret key. In fact the tests can all be performed by an 315 eavesdropper. 317 The situation when the failure occurs in the Create Child SA exchange 318 is different, since everything is protected by an IKE SA. The peers 319 are authenticated, and error notifications can be relied on. See 320 Sec. 2.21.3 of [RFC5996] for more details on error handling in this 321 case. 323 5. IANA Considerations 325 This document requests that IANA should add a column named "Recipient 326 Tests" to the IKEv2 DH Group Transform IDs Registry 327 [IANA-DH-Registry]. 329 This column should initially be populated as per the following table. 331 +------------------------------------+---------------------+ 332 | Number | Recipient Tests | 333 +------------------------------------+---------------------+ 334 | 1, 2, 5, 14, 15, 16, 17, 18 | [current], Sec. 2.1 | 335 | 22, 23, 24 | [current], Sec. 2.2 | 336 | 19, 20, 21, 25, 26, 27, 28, 29, 30 | [current], Sec. 2.3 | 337 +------------------------------------+---------------------+ 339 Note to RFC Editor: please replace [current] by the RFC number 340 assigned to this document. 342 Groups 27-30 have been recently defined in 343 [I-D.merkle-ikev2-ke-brainpool]. 345 Future documents that define new DH groups for IKEv2 are REQUIRED to 346 provide this information for each new group, possibly by referring to 347 the current document. 349 6. Acknowledgements 351 We would like to thank Dan Harkins who initially raised this issue on 352 the ipsec mailing list. Thanks to Tero Kivinen and Rene Struik for 353 their useful comments. 355 The document was prepared using the lyx2rfc tool, created by Nico 356 Williams. 358 7. References 359 7.1. Normative References 361 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 362 Requirement Levels", BCP 14, RFC 2119, March 1997. 364 [RFC5996] Kaufman, C., Hoffman, P., Nir, Y., and P. Eronen, 365 "Internet Key Exchange Protocol Version 2 (IKEv2)", 366 RFC 5996, September 2010. 368 7.2. Informative References 370 [RFC2412] Orman, H., "The OAKLEY Key Determination Protocol", 371 RFC 2412, November 1998. 373 [RFC3526] Kivinen, T. and M. Kojo, "More Modular Exponential (MODP) 374 Diffie-Hellman groups for Internet Key Exchange (IKE)", 375 RFC 3526, May 2003. 377 [RFC5114] Lepinski, M. and S. Kent, "Additional Diffie-Hellman 378 Groups for Use with IETF Standards", RFC 5114, 379 January 2008. 381 [RFC5903] Fu, D. and J. Solinas, "Elliptic Curve Groups modulo a 382 Prime (ECP Groups) for IKE and IKEv2", RFC 5903, 383 June 2010. 385 [I-D.merkle-ikev2-ke-brainpool] 386 Merkle, J. and M. Lochter, "Using the ECC Brainpool Curves 387 for IKEv2 Key Exchange", 388 draft-merkle-ikev2-ke-brainpool-04 (work in progress), 389 April 2013. 391 [NIST-800-56A] 392 National Institute of Standards and Technology (NIST), 393 "Recommendation for Pair-Wise Key Establishment Schemes 394 Using Discrete Logarithm Cryptography (Revised)", NIST PUB 395 800-56A, March 2007. 397 [Kocher] Kocher, P., "Timing Attacks on Implementations of Diffie- 398 Hellman, RSA, DSS, and Other Systems", December 1996, 399 . 401 [Menezes] Menezes, A. and B. Ustaoglu, "On Reusing Ephemeral Keys In 402 Diffie-Hellman Key Agreement Protocols", December 2008, . 406 [IANA-DH-Registry] 407 IANA, "Internet Key Exchange Version 2 (IKEv2) Parameters, 408 Transform Type 4 - Diffie-Hellman Group Transform IDs", 409 Jan. 2005, . 412 Appendix A. Appendix: Change Log 414 Note to RFC Editor: please remove this section before publication. 416 A.1. -03 418 o Added the Brainpool curves to the IANA registration table. 420 A.2. -02 422 o Based on Tero's review: Improved the protocol behavior, and 423 mentioned that these checks apply to Create Child SA. Added a 424 discussion of DH timing attacks, stolen from RFC 2412. 426 A.3. -01 428 o Corrected an author's name that was misspelled. 429 o Added recipient behavior if a test fails, and the related security 430 considerations. 432 A.4. -00 434 o First WG document. 435 o Clarified IANA actions. 436 o Discussion of potential future groups not covered here. 437 o Clarification re: practicality of recipient tests for DSA groups. 439 Authors' Addresses 441 Yaron Sheffer 442 Porticor 443 10 Yirmiyahu St. 444 Ramat HaSharon 47298 445 Israel 447 Email: yaronf.ietf@gmail.com 448 Scott Fluhrer 449 Cisco Systems 450 1414 Massachusetts Ave. 451 Boxborough, MA 01719 452 USA 454 Email: sfluhrer@cisco.com