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