idnits 2.17.1 draft-ietf-kitten-password-storage-01.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: ---------------------------------------------------------------------------- == There are 2 instances of lines with non-ascii characters in the document. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (29 October 2020) is 1273 days in the past. Is this intentional? Checking references for intended status: Best Current Practice ---------------------------------------------------------------------------- (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 4949 == Outdated reference: A later version (-13) exists of draft-irtf-cfrg-argon2-10 Summary: 1 error (**), 0 flaws (~~), 3 warnings (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Common Authentication Technology Next Generation S. Whited 3 Internet-Draft 29 October 2020 4 Intended status: Best Current Practice 5 Expires: 2 May 2021 7 Best practices for password hashing and storage 8 draft-ietf-kitten-password-storage-01 10 Abstract 12 This document outlines best practices for handling user passwords and 13 other authenticator secrets in client-server systems making use of 14 SASL. 16 Status of This Memo 18 This Internet-Draft is submitted in full conformance with the 19 provisions of BCP 78 and BCP 79. 21 Internet-Drafts are working documents of the Internet Engineering 22 Task Force (IETF). Note that other groups may also distribute 23 working documents as Internet-Drafts. The list of current Internet- 24 Drafts is at https://datatracker.ietf.org/drafts/current/. 26 Internet-Drafts are draft documents valid for a maximum of six months 27 and may be updated, replaced, or obsoleted by other documents at any 28 time. It is inappropriate to use Internet-Drafts as reference 29 material or to cite them other than as "work in progress." 31 This Internet-Draft will expire on 2 May 2021. 33 Copyright Notice 35 Copyright (c) 2020 IETF Trust and the persons identified as the 36 document authors. All rights reserved. 38 This document is subject to BCP 78 and the IETF Trust's Legal 39 Provisions Relating to IETF Documents (https://trustee.ietf.org/ 40 license-info) in effect on the date of publication of this document. 41 Please review these documents carefully, as they describe your rights 42 and restrictions with respect to this document. Code Components 43 extracted from this document must include Simplified BSD License text 44 as described in Section 4.e of the Trust Legal Provisions and are 45 provided without warranty as described in the Simplified BSD License. 47 Table of Contents 49 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 50 1.1. Conventions and Terminology . . . . . . . . . . . . . . . 2 51 2. SASL Mechanisms . . . . . . . . . . . . . . . . . . . . . . . 3 52 3. Client Best Practices . . . . . . . . . . . . . . . . . . . . 3 53 3.1. Mechanism Pinning . . . . . . . . . . . . . . . . . . . . 4 54 3.2. Storage . . . . . . . . . . . . . . . . . . . . . . . . . 5 55 4. Server Best Practices . . . . . . . . . . . . . . . . . . . . 5 56 4.1. Additional SASL Requirements . . . . . . . . . . . . . . 5 57 4.2. Storage . . . . . . . . . . . . . . . . . . . . . . . . . 5 58 4.3. Authentication and Rotation . . . . . . . . . . . . . . . 6 59 5. KDF Recommendations . . . . . . . . . . . . . . . . . . . . . 6 60 5.1. Argon2 . . . . . . . . . . . . . . . . . . . . . . . . . 6 61 5.2. Bcrypt . . . . . . . . . . . . . . . . . . . . . . . . . 7 62 5.3. PBKDF2 . . . . . . . . . . . . . . . . . . . . . . . . . 7 63 5.4. Scrypt . . . . . . . . . . . . . . . . . . . . . . . . . 8 64 6. Password Complexity Requirements . . . . . . . . . . . . . . 8 65 7. Internationalization Considerations . . . . . . . . . . . . . 9 66 8. Security Considerations . . . . . . . . . . . . . . . . . . . 9 67 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 10 68 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 10 69 10.1. Normative References . . . . . . . . . . . . . . . . . . 10 70 10.2. Informative References . . . . . . . . . . . . . . . . . 10 71 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 13 72 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 13 74 1. Introduction 76 Following best practices when hashing and storing passwords for use 77 with SASL impacts a great deal more than just a user's identity. It 78 also affects usability, backwards compatibility, and interoperability 79 by determining what authentication and authorization mechanisms can 80 be used. 82 1.1. Conventions and Terminology 84 Various security-related terms are to be understood in the sense 85 defined in [RFC4949]. Some may also be defined in [NISTSP63-3] 86 Appendix A.1 and in [NISTSP132] section 3.1. 88 Throughout this document the term "password" is used to mean any 89 password, passphrase, PIN, or other memorized secret. 91 Other common terms used throughout this document include: 93 Mechanism pinning A security mechanism which allows SASL clients to 94 resist downgrade attacks. Clients that implement mechanism 95 pinning remember the perceived strength of the SASL mechanism used 96 in a previous successful authentication attempt and thereafter 97 only authenticate using mechanisms of equal or higher perceived 98 strength. 100 Pepper A secret added to a password hash like a salt. Unlike a 101 salt, peppers are secret and the same pepper may be reused for 102 many hashed passwords. They must not be stored alongside the 103 hashed password. 105 Salt In this document salt is used as defined in [RFC4949]. 107 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 108 "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and 109 "OPTIONAL" in this document are to be interpreted as described in BCP 110 14 [RFC2119] [RFC8174] when, and only when, they appear in all 111 capitals, as shown here. 113 2. SASL Mechanisms 115 For clients and servers that support password based authentication 116 using SASL [RFC4422] it is RECOMMENDED that the following mechanisms 117 be implemented: 119 * SCRAM-SHA-256 [RFC7677] 121 * SCRAM-SHA-256-PLUS [RFC7677] 123 System entities SHOULD NOT invent their own mechanisms that have not 124 been standardized by the IETF or another reputable standards body. 125 Similarly, entities SHOULD NOT implement any mechanism with a usage 126 status of "OBSOLETE", "MUST NOT be used", or "LIMITED" in the IANA 127 SASL Mechanisms Registry [IANA.sasl.mechanisms]. 129 The SASL mechanisms discussed in this document do not negotiate a 130 security layer. Because of this a strong security layer such as TLS 131 [RFC8446] MUST be negotiated before SASL mechanisms can be advertised 132 or negotiated. 134 3. Client Best Practices 135 3.1. Mechanism Pinning 137 Clients often maintain a list of preferred SASL mechanisms, generally 138 ordered by perceived strength to enable strong authentication. To 139 prevent downgrade attacks by a malicious actor that has successfully 140 man in the middled a connection, or compromised a trusted server's 141 configuration, clients SHOULD implement "mechanism pinning". That 142 is, after the first successful authentication with a strong 143 mechanism, clients SHOULD make a record of the authentication and 144 thereafter only advertise and use mechanisms of equal or higher 145 perceived strength. 147 The following mechanisms are ordered by their perceived strength from 148 strongest to weakest with mechanisms of equal strength on the same 149 line. The remainder of this section is merely informative. In 150 particular this example does not imply that mechanisms in this list 151 should or should not be implemented. 153 1. EXTERNAL 155 2. SCRAM-SHA-1-PLUS, SCRAM-SHA-256-PLUS 157 3. SCRAM-SHA-1, SCRAM-SHA-256 159 4. PLAIN 161 5. DIGEST-MD5, CRAM-MD5 163 The EXTERNAL mechanism defined in [RFC4422] appendix A is placed at 164 the top of the list. However, its perceived strength depends on the 165 underlying authentication protocol. In this example, we assume that 166 TLS [RFC8446] services are being used. 168 The channel binding ("-PLUS") variants of SCRAM [RFC5802] are listed 169 above their non-channel binding cousins, but may not always be 170 available depending on the type of channel binding data available to 171 the SASL negotiator. 173 The PLAIN mechanism sends the username and password in plain text, 174 but does allow for the use of a strong key derivation function (KDF) 175 for the stored version of the password on the server. 177 Finally, the DIGEST-MD5 and CRAM-MD5 mechanisms are listed last 178 because they use weak hashes and ciphers and prevent the server from 179 storing passwords using a KDF. For a list of problems with DIGEST- 180 MD5 see [RFC6331]. 182 3.2. Storage 184 Clients SHOULD always store authenticators in a trusted and encrypted 185 keystore such as the system keystore, or an encrypted store created 186 specifically for the clients use. They SHOULD NOT store 187 authenticators as plain text. 189 If clients know that they will only ever authenticate using a 190 mechanism such as SCRAM [RFC5802] where the original password is not 191 needed after the first authentication attempt they SHOULD store the 192 SCRAM bits or the hashed and salted password instead of the original 193 password. However, if backwards compatibility with servers that only 194 support the PLAIN mechanism or other mechanisms that require using 195 the original password is required, clients MAY choose to store the 196 original password so long as an appropriate keystore is used. 198 4. Server Best Practices 200 4.1. Additional SASL Requirements 202 Servers MUST NOT support any mechanism that would require 203 authenticators to be stored in such a way that they could be 204 recovered in plain text from the stored information. This includes 205 mechanisms that store authenticators using reversable encryption, 206 obsolete hashing mechanisms such as MD5 or hashing mechanisms that 207 are cryptographically secure but designed for speed such as SHA256. 209 4.2. Storage 211 Servers MUST always store passwords only after they have been salted 212 and hashed using a strong KDF. A distinct salt SHOULD be used for 213 each user, and each SCRAM family supported. Salts SHOULD be 214 generated using a cryptographically secure random number generator. 215 The salt MAY be stored in the same datastore as the password. If it 216 is stored alongside the password, it SHOULD be combined with a pepper 217 stored in the application configuration, or a secure location other 218 than the datastore containing the salts. 220 The following restrictions MUST be observed when generating salts and 221 peppers, more up to date numbers may be found in 222 [OWASP.CS.passwords]. 224 +=======================+==========+ 225 | Parameter | Value | 226 +=======================+==========+ 227 | Minimum Salt Length | 16 bytes | 228 +-----------------------+----------+ 229 | Minimum Pepper Length | 32 bytes | 230 +-----------------------+----------+ 232 Table 1: Common Parameters 234 4.3. Authentication and Rotation 236 When authenticating using PLAIN or similar mechanisms that involve 237 transmitting the original password to the server the password MUST be 238 hashed and compared against the salted and hashed password in the 239 database using a constant time comparison. 241 Each time a password is changed a new random salt MUST be created and 242 the iteration count and pepper (if applicable) MUST be updated to the 243 latest value required by server policy. 245 If a pepper is used, consideration should be taken to ensure that it 246 can be easily rotated. For example, multiple peppers could be 247 stored. New passwords and reset passwords would use the newest 248 pepper and a hash of the pepper using a cryptographically secure hash 249 function such as SHA256 could then be stored in the database next to 250 the salt so that future logins can identify which pepper in the list 251 was used. This is just one example, pepper rotation schemes are 252 outside the scope of this document. 254 5. KDF Recommendations 256 When properly configured, the following commonly used KDFs create 257 suitable password hash results for server side storage. The 258 recommendations in this section may change depending on the hardware 259 being used and the security level required for the application. 261 With all KDFs proper tuning is required to ensure that it meets the 262 needs of the specific application or service. For persistent login 263 an iteration count or work factor that adds approximately a quarter 264 of a second to login may be an acceptable tradeoff since logins are 265 relatively rare. By contrast, verification tokens that are generated 266 many times per second may need to use a much lower work factor. 268 5.1. Argon2 270 Argon2 [ARGON2ESP] is the 2015 winner of the Password Hashing 271 Competition and has been recomended by OWASP for password hashing. 273 Security considerations, test vectors, and parameters for tuning 274 argon2 can be found in [I-D.irtf-cfrg-argon2]. They are copied here 275 for easier reference. 277 +===========================+==============+ 278 | Parameter | Value | 279 +===========================+==============+ 280 | Degree of parallelism (p) | 1 | 281 +---------------------------+--------------+ 282 | Memory size (m) | 32*1024 | 283 +---------------------------+--------------+ 284 | Number of iterations (t) | 1 | 285 +---------------------------+--------------+ 286 | Algorithm type (y) | Argon2id (2) | 287 +---------------------------+--------------+ 289 Table 2: Argon Parameters 291 5.2. Bcrypt 293 bcrypt [BCRYPT] is a Blowfish-based KDF that is the current OWASP 294 recommendation for password hashing. 296 +=========================+=======================+ 297 | Parameter | Value | 298 +=========================+=======================+ 299 | Recommended Cost | 12 | 300 +-------------------------+-----------------------+ 301 | Maximum Password Length | 50-72 bytes depending | 302 | | on the implementation | 303 +-------------------------+-----------------------+ 305 Table 3: Bcrypt Parameters 307 5.3. PBKDF2 309 PBKDF2 [RFC8018] is used by the SCRAM [RFC5802] family of SASL 310 mechanisms. 312 +=============================+==================================+ 313 | Parameter | Value | 314 +=============================+==================================+ 315 | Minimum iteration count (c) | 10,000 | 316 +-----------------------------+----------------------------------+ 317 | Hash | SHA256 | 318 +-----------------------------+----------------------------------+ 319 | Output length (dkLen) | hLen (length of the chosen hash) | 320 +-----------------------------+----------------------------------+ 322 Table 4: PBKDF2 Parameters 324 5.4. Scrypt 326 The [SCRYPT] KDF is designed to be memory-hard and sequential memory- 327 hard to prevent against custom hardware based attacks. 329 Security considerations, test vectors, and further notes on tuning 330 scrypt may be found in [RFC7914]. 332 +===========+================+ 333 | Parameter | Value | 334 +===========+================+ 335 | N | 32768 (N=2^15) | 336 +-----------+----------------+ 337 | r | 8 | 338 +-----------+----------------+ 339 | p | 1 | 340 +-----------+----------------+ 342 Table 5: Scrypt Parameters 344 6. Password Complexity Requirements 346 Before any other password complexity requirements are checked, the 347 preparation and enforcement steps of the OpaqueString profile of 348 [RFC8265] SHOULD be applied (for more information see the 349 Internationalization Considerations section). Entities SHOULD 350 enforce a minimum length of 8 characters for user passwords. If 351 using a mechanism such as PLAIN where the server performs hashing on 352 the original password, a maximum length between 64 and 128 characters 353 MAY be imposed to prevent denial of service (DoS) attacks. Entities 354 SHOULD NOT apply any other password restrictions. 356 In addition to these password complexity requirements, servers SHOULD 357 maintain a password blocklist and reject attempts by a claimant to 358 use passwords on the blocklist during registration or password reset. 359 The contents of this blocklist are a matter of server policy. Some 360 common recommendations include lists of common passwords that are not 361 otherwise prevented by length requirements, and passwords present in 362 known breaches. 364 7. Internationalization Considerations 366 The PRECIS framework (Preparation, Enforcement, and Comparison of 367 Internationalized Strings) defined in [RFC8264] is used to enforce 368 internationalization rules on strings and to prevent common 369 application security issues arrising from allowing the full range of 370 Unicode codepoints in usernames, passwords, and other identifiers. 371 The OpaqueString profile of [RFC8265] is used in this document to 372 ensure that codepoints in passwords are treated carefully and 373 consistently. This ensures that users typing certain characters on 374 different keyboards that may provide different versions of the same 375 character will still be able to log in. For example, some keyboards 376 may output the full-width version of a character while other 377 keyboards output the half-width version of the same character. The 378 Width Mapping rule of the OpaqueString profile addresses this and 379 ensures that comparison succeeds and the claimant is able to be 380 authenticated. 382 8. Security Considerations 384 This document contains recommendations that are likely to change over 385 time. It should be reviewed regularly to ensure that it remains 386 accurate and up to date. Many of the recommendations in this 387 document were taken from [OWASP.CS.passwords], [NISTSP63b], and 388 [NISTSP132]. 390 The "-PLUS" variants of SCRAM [RFC5802] support channel binding to 391 their underlying security layer, but lack a mechanism for negotiating 392 what type of channel binding to use. In [RFC5802] the tls-unique 393 [RFC5929] channel binding mechanism is specified as the default, and 394 it is therefore likely to be used in most applications that support 395 channel binding. However, in the absence of the TLS extended master 396 secret fix [RFC7627] and the renegotiation indication TLS extension 397 [RFC5746] the tls-unique and tls-server-endpoint channel binding data 398 can be forged by an attacker that can MITM the connection. Before 399 advertising a channel binding SASL mechanism, entities MUST ensure 400 that both the TLS extended master secret fix and the renegotiation 401 indication extension are in place and that the connection has not 402 been renegotiated. 404 For TLS 1.3 [RFC8446] no channel binding types are currently defined. 405 Channel binding SASL mechanisms MUST NOT be advertised or negotiated 406 over a TLS 1.3 channel until such types are defined. 408 9. IANA Considerations 410 This document has no actions for IANA. 412 10. References 414 10.1. Normative References 416 [IANA.sasl.mechanisms] 417 IETF, "Simple Authentication and Security Layer (SASL) 418 Mechanisms", November 2015, 419 . 422 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 423 Requirement Levels", BCP 14, RFC 2119, 424 DOI 10.17487/RFC2119, March 1997, 425 . 427 [RFC4949] Shirey, R., "Internet Security Glossary, Version 2", 428 FYI 36, RFC 4949, DOI 10.17487/RFC4949, August 2007, 429 . 431 [RFC5746] Rescorla, E., Ray, M., Dispensa, S., and N. Oskov, 432 "Transport Layer Security (TLS) Renegotiation Indication 433 Extension", RFC 5746, DOI 10.17487/RFC5746, February 2010, 434 . 436 [RFC5929] Altman, J., Williams, N., and L. Zhu, "Channel Bindings 437 for TLS", RFC 5929, DOI 10.17487/RFC5929, July 2010, 438 . 440 [RFC7627] Bhargavan, K., Ed., Delignat-Lavaud, A., Pironti, A., 441 Langley, A., and M. Ray, "Transport Layer Security (TLS) 442 Session Hash and Extended Master Secret Extension", 443 RFC 7627, DOI 10.17487/RFC7627, September 2015, 444 . 446 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 447 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 448 May 2017, . 450 10.2. Informative References 452 [ARGON2ESP] 453 Biryukov, A., Dinu, D., and D. Khovratovich, "Argon2: New 454 Generation of Memory-Hard Functions for Password Hashing 455 and Other Applications", Euro SnP 2016, March 2016, 456 . 458 [BCRYPT] Provos, N. and D. Mazières, "A Future-Adaptable Password 459 Scheme", USENIX 1999 460 https://www.usenix.org/legacy/event/usenix99/provos/ 461 provos.pdf, June 1999. 463 [I-D.irtf-cfrg-argon2] 464 Biryukov, A., Dinu, D., Khovratovich, D., and S. 465 Josefsson, "The memory-hard Argon2 password hash and 466 proof-of-work function", Work in Progress, Internet-Draft, 467 draft-irtf-cfrg-argon2-10, 25 March 2020, 468 . 470 [NISTSP132] 471 Turan, M., Barker, E., Burr, W., and L. Chen, 472 "Recommendation for Password-Based Key Derivation Part 1: 473 Storage Applications", NIST Special Publication SP 474 800-132, DOI 10.6028/NIST.SP.800-132, December 2010, 475 . 478 [NISTSP63-3] 479 Grassi, P., Garcia, M., and J. Fenton, "Digital Identity 480 Guidelines", NIST Special Publication SP 800-63-3, 481 DOI 10.6028/NIST.SP.800-63-3, June 2017, 482 . 485 [NISTSP63b] 486 Grassi, P., Fenton, J., Newton, E., Perlner, R., 487 Regenscheid, A., Burr, W., Richer, J., Lefkovitz, N., 488 Danker, J., Choong, Y., Greene, K., and M. Theofanos, 489 "Digital Identity Guidelines: Authentication and Lifecycle 490 Management", NIST Special Publication SP 800-63b, 491 DOI 10.6028/NIST.SP.800-63b, June 2017, 492 . 495 [OWASP.CS.passwords] 496 Manico, J., Saad, E., Maćkowski, J., and R. Bailey, 497 "Password Storage", OWASP Cheat Sheet Password Storage, 498 April 2020, 499 . 502 [RFC4422] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 503 Authentication and Security Layer (SASL)", RFC 4422, 504 DOI 10.17487/RFC4422, June 2006, 505 . 507 [RFC5802] Newman, C., Menon-Sen, A., Melnikov, A., and N. Williams, 508 "Salted Challenge Response Authentication Mechanism 509 (SCRAM) SASL and GSS-API Mechanisms", RFC 5802, 510 DOI 10.17487/RFC5802, July 2010, 511 . 513 [RFC6331] Melnikov, A., "Moving DIGEST-MD5 to Historic", RFC 6331, 514 DOI 10.17487/RFC6331, July 2011, 515 . 517 [RFC7677] Hansen, T., "SCRAM-SHA-256 and SCRAM-SHA-256-PLUS Simple 518 Authentication and Security Layer (SASL) Mechanisms", 519 RFC 7677, DOI 10.17487/RFC7677, November 2015, 520 . 522 [RFC7914] Percival, C. and S. Josefsson, "The scrypt Password-Based 523 Key Derivation Function", RFC 7914, DOI 10.17487/RFC7914, 524 August 2016, . 526 [RFC8018] Moriarty, K., Ed., Kaliski, B., and A. Rusch, "PKCS #5: 527 Password-Based Cryptography Specification Version 2.1", 528 RFC 8018, DOI 10.17487/RFC8018, January 2017, 529 . 531 [RFC8264] Saint-Andre, P. and M. Blanchet, "PRECIS Framework: 532 Preparation, Enforcement, and Comparison of 533 Internationalized Strings in Application Protocols", 534 RFC 8264, DOI 10.17487/RFC8264, October 2017, 535 . 537 [RFC8265] Saint-Andre, P. and A. Melnikov, "Preparation, 538 Enforcement, and Comparison of Internationalized Strings 539 Representing Usernames and Passwords", RFC 8265, 540 DOI 10.17487/RFC8265, October 2017, 541 . 543 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 544 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 545 . 547 [SCRYPT] Percival, C., "Stronger key derivation via sequential 548 memory-hard functions", 549 BSDCan'09 http://www.tarsnap.com/scrypt/scrypt.pdf, May 550 2009. 552 Appendix A. Acknowledgments 554 The author would like to thank the civil servants at the National 555 Institute of Standards and Technology for their work on the Special 556 Publications series. U.S. executive agencies are an undervalued 557 national treasure, and they deserve our thanks. 559 Thanks also to Cameron Paul and Thomas Copeland for their reviews and 560 suggestions. 562 Author's Address 564 Sam Whited 565 Atlanta, GA 566 United States of America 568 Email: sam@samwhited.com 569 URI: https://blog.samwhited.com/