idnits 2.17.1 draft-ietf-kitten-password-storage-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: ---------------------------------------------------------------------------- == 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 (22 November 2020) is 1249 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 22 November 2020 4 Intended status: Best Current Practice 5 Expires: 26 May 2021 7 Best practices for password hashing and storage 8 draft-ietf-kitten-password-storage-02 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 26 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 . . . . . . . . . . . . . . . . . . . . . . . . . 7 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-256-PLUS 157 3. SCRAM-SHA-1-PLUS 159 4. SCRAM-SHA-256 161 5. SCRAM-SHA-1 163 6. PLAIN 165 7. DIGEST-MD5, CRAM-MD5 167 The EXTERNAL mechanism defined in [RFC4422] appendix A is placed at 168 the top of the list. However, its perceived strength depends on the 169 underlying authentication protocol. In this example, we assume that 170 TLS [RFC8446] services are being used. 172 The channel binding ("-PLUS") variants of SCRAM [RFC5802] are listed 173 above their non-channel binding cousins, but may not always be 174 available depending on the type of channel binding data available to 175 the SASL negotiator. 177 The PLAIN mechanism sends the username and password in plain text, 178 but does allow for the use of a strong key derivation function (KDF) 179 for the stored version of the password on the server. 181 Finally, the DIGEST-MD5 and CRAM-MD5 mechanisms are listed last 182 because they use weak hashes and ciphers and prevent the server from 183 storing passwords using a KDF. For a list of problems with DIGEST- 184 MD5 see [RFC6331]. 186 3.2. Storage 188 Clients SHOULD always store authenticators in a trusted and encrypted 189 keystore such as the system keystore, or an encrypted store created 190 specifically for the clients use. They SHOULD NOT store 191 authenticators as plain text. 193 If clients know that they will only ever authenticate using a 194 mechanism such as SCRAM [RFC5802] where the original password is not 195 needed after the first authentication attempt they SHOULD store the 196 SCRAM bits or the hashed and salted password instead of the original 197 password. However, if backwards compatibility with servers that only 198 support the PLAIN mechanism or other mechanisms that require using 199 the original password is required, clients MAY choose to store the 200 original password so long as an appropriate keystore is used. 202 4. Server Best Practices 204 4.1. Additional SASL Requirements 206 Servers MUST NOT support any mechanism that would require 207 authenticators to be stored in such a way that they could be 208 recovered in plain text from the stored information. This includes 209 mechanisms that store authenticators using reversable encryption, 210 obsolete hashing mechanisms such as MD5 or hashing mechanisms that 211 are cryptographically secure but designed for speed such as SHA256. 213 4.2. Storage 215 Servers MUST always store passwords only after they have been salted, 216 peppered (if possible with the given authentication mechanism), and 217 hashed using a strong KDF. A distinct salt SHOULD be used for each 218 user, and each SCRAM family supported. Salts SHOULD be generated 219 using a cryptographically secure random number generator. The salt 220 MAY be stored in the same datastore as the password. A pepper stored 221 in the application configuration, or a secure location other than the 222 datastore containing the salts, SHOULD be combined with the password 223 before hashing if possible with the given authentication mechanism. 224 Peppers SHOULD NOT be combined with the salt because the salt is not 225 secret and may appear in the final hash output. 227 The following restrictions MUST be observed when generating salts and 228 peppers, more up to date numbers may be found in 229 [OWASP.CS.passwords]. 231 +=======================+==========+ 232 | Parameter | Value | 233 +=======================+==========+ 234 | Minimum Salt Length | 16 bytes | 235 +-----------------------+----------+ 236 | Minimum Pepper Length | 32 bytes | 237 +-----------------------+----------+ 239 Table 1: Common Parameters 241 4.3. Authentication and Rotation 243 When authenticating using PLAIN or similar mechanisms that involve 244 transmitting the original password to the server the password MUST be 245 hashed and compared against the salted and hashed password in the 246 database using a constant time comparison. 248 Each time a password is changed a new random salt MUST be created and 249 the iteration count and pepper (if applicable) MUST be updated to the 250 latest value required by server policy. 252 If a pepper is used, consideration should be taken to ensure that it 253 can be easily rotated. For example, multiple peppers could be 254 stored. New passwords and reset passwords would use the newest 255 pepper and a hash of the pepper using a cryptographically secure hash 256 function such as SHA256 could then be stored in the database next to 257 the salt so that future logins can identify which pepper in the list 258 was used. This is just one example, pepper rotation schemes are 259 outside the scope of this document. 261 5. KDF Recommendations 263 When properly configured, the following commonly used KDFs create 264 suitable password hash results for server side storage. The 265 recommendations in this section may change depending on the hardware 266 being used and the security level required for the application. 268 With all KDFs proper tuning is required to ensure that it meets the 269 needs of the specific application or service. For persistent login 270 an iteration count or work factor that adds approximately a quarter 271 of a second to login may be an acceptable tradeoff since logins are 272 relatively rare. By contrast, verification tokens that are generated 273 many times per second may need to use a much lower work factor. 275 5.1. Argon2 277 Argon2 [ARGON2ESP] is the 2015 winner of the Password Hashing 278 Competition and has been recomended by OWASP for password hashing. 280 Security considerations, test vectors, and parameters for tuning 281 argon2 can be found in [I-D.irtf-cfrg-argon2]. They are copied here 282 for easier reference. 284 +==================================+==============+ 285 | Parameter | Value | 286 +==================================+==============+ 287 | Degree of parallelism (p) | 1 | 288 +----------------------------------+--------------+ 289 | Minimum memory size (m) | 32*1024 | 290 +----------------------------------+--------------+ 291 | Minimum number of iterations (t) | 1 | 292 +----------------------------------+--------------+ 293 | Algorithm type (y) | Argon2id (2) | 294 +----------------------------------+--------------+ 296 Table 2: Argon Parameters 298 5.2. Bcrypt 300 bcrypt [BCRYPT] is a Blowfish-based KDF that is the current OWASP 301 recommendation for password hashing. 303 +=========================+=======================+ 304 | Parameter | Value | 305 +=========================+=======================+ 306 | Recommended Cost | 12 | 307 +-------------------------+-----------------------+ 308 | Maximum Password Length | 50-72 bytes depending | 309 | | on the implementation | 310 +-------------------------+-----------------------+ 312 Table 3: Bcrypt Parameters 314 5.3. PBKDF2 316 PBKDF2 [RFC8018] is used by the SCRAM [RFC5802] family of SASL 317 mechanisms. 319 +=============================+==================================+ 320 | Parameter | Value | 321 +=============================+==================================+ 322 | Minimum iteration count (c) | 10,000 | 323 +-----------------------------+----------------------------------+ 324 | Hash | SHA256 | 325 +-----------------------------+----------------------------------+ 326 | Output length (dkLen) | hLen (length of the chosen hash) | 327 +-----------------------------+----------------------------------+ 329 Table 4: PBKDF2 Parameters 331 5.4. Scrypt 333 The [SCRYPT] KDF is designed to be memory-hard and sequential memory- 334 hard to prevent against custom hardware based attacks. 336 Security considerations, test vectors, and further notes on tuning 337 scrypt may be found in [RFC7914]. 339 +=======================================+==================+ 340 | Parameter | Value | 341 +=======================================+==================+ 342 | Minimum CPU/Memory cost parameter (N) | 32768 (N=2^15) | 343 +---------------------------------------+------------------+ 344 | Blocksize (r) | 8 | 345 +---------------------------------------+------------------+ 346 | Parallelization parameter (p) | 1 | 347 +---------------------------------------+------------------+ 348 | Output length (dkLen) | hLen (length of | 349 | | the chosen hash) | 350 +---------------------------------------+------------------+ 352 Table 5: Scrypt Parameters 354 6. Password Complexity Requirements 356 Before any other password complexity requirements are checked, the 357 preparation and enforcement steps of the OpaqueString profile of 358 [RFC8265] SHOULD be applied (for more information see the 359 Internationalization Considerations section). Entities SHOULD 360 enforce a minimum length of 8 characters for user passwords. If 361 using a mechanism such as PLAIN where the server performs hashing on 362 the original password, a maximum length between 64 and 128 characters 363 MAY be imposed to prevent denial of service (DoS) attacks. Entities 364 SHOULD NOT apply any other password restrictions. 366 In addition to these password complexity requirements, servers SHOULD 367 maintain a password blocklist and reject attempts by a claimant to 368 use passwords on the blocklist during registration or password reset. 369 The contents of this blocklist are a matter of server policy. Some 370 common recommendations include lists of common passwords that are not 371 otherwise prevented by length requirements, and passwords present in 372 known breaches. 374 7. Internationalization Considerations 376 The PRECIS framework (Preparation, Enforcement, and Comparison of 377 Internationalized Strings) defined in [RFC8264] is used to enforce 378 internationalization rules on strings and to prevent common 379 application security issues arrising from allowing the full range of 380 Unicode codepoints in usernames, passwords, and other identifiers. 381 The OpaqueString profile of [RFC8265] is used in this document to 382 ensure that codepoints in passwords are treated carefully and 383 consistently. This ensures that users typing certain characters on 384 different keyboards that may provide different versions of the same 385 character will still be able to log in. For example, some keyboards 386 may output the full-width version of a character while other 387 keyboards output the half-width version of the same character. The 388 Width Mapping rule of the OpaqueString profile addresses this and 389 ensures that comparison succeeds and the claimant is able to be 390 authenticated. 392 8. Security Considerations 394 This document contains recommendations that are likely to change over 395 time. It should be reviewed regularly to ensure that it remains 396 accurate and up to date. Many of the recommendations in this 397 document were taken from [OWASP.CS.passwords], [NISTSP63b], and 398 [NISTSP132]. 400 The "-PLUS" variants of SCRAM [RFC5802] support channel binding to 401 their underlying security layer, but lack a mechanism for negotiating 402 what type of channel binding to use. In [RFC5802] the tls-unique 403 [RFC5929] channel binding mechanism is specified as the default, and 404 it is therefore likely to be used in most applications that support 405 channel binding. However, in the absence of the TLS extended master 406 secret fix [RFC7627] and the renegotiation indication TLS extension 407 [RFC5746] the tls-unique and tls-server-endpoint channel binding data 408 can be forged by an attacker that can MITM the connection. Before 409 advertising a channel binding SASL mechanism, entities MUST ensure 410 that both the TLS extended master secret fix and the renegotiation 411 indication extension are in place and that the connection has not 412 been renegotiated. 414 For TLS 1.3 [RFC8446] no channel binding types are currently defined. 415 Channel binding SASL mechanisms MUST NOT be advertised or negotiated 416 over a TLS 1.3 channel until such types are defined. 418 9. IANA Considerations 420 This document has no actions for IANA. 422 10. References 424 10.1. Normative References 426 [IANA.sasl.mechanisms] 427 IETF, "Simple Authentication and Security Layer (SASL) 428 Mechanisms", November 2015, 429 . 432 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 433 Requirement Levels", BCP 14, RFC 2119, 434 DOI 10.17487/RFC2119, March 1997, 435 . 437 [RFC4949] Shirey, R., "Internet Security Glossary, Version 2", 438 FYI 36, RFC 4949, DOI 10.17487/RFC4949, August 2007, 439 . 441 [RFC5746] Rescorla, E., Ray, M., Dispensa, S., and N. Oskov, 442 "Transport Layer Security (TLS) Renegotiation Indication 443 Extension", RFC 5746, DOI 10.17487/RFC5746, February 2010, 444 . 446 [RFC5929] Altman, J., Williams, N., and L. Zhu, "Channel Bindings 447 for TLS", RFC 5929, DOI 10.17487/RFC5929, July 2010, 448 . 450 [RFC7627] Bhargavan, K., Ed., Delignat-Lavaud, A., Pironti, A., 451 Langley, A., and M. Ray, "Transport Layer Security (TLS) 452 Session Hash and Extended Master Secret Extension", 453 RFC 7627, DOI 10.17487/RFC7627, September 2015, 454 . 456 [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 457 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, 458 May 2017, . 460 10.2. Informative References 462 [ARGON2ESP] 463 Biryukov, A., Dinu, D., and D. Khovratovich, "Argon2: New 464 Generation of Memory-Hard Functions for Password Hashing 465 and Other Applications", Euro SnP 2016, March 2016, 466 . 468 [BCRYPT] Provos, N. and D. Mazières, "A Future-Adaptable Password 469 Scheme", USENIX 1999 470 https://www.usenix.org/legacy/event/usenix99/provos/ 471 provos.pdf, June 1999. 473 [I-D.irtf-cfrg-argon2] 474 Biryukov, A., Dinu, D., Khovratovich, D., and S. 475 Josefsson, "The memory-hard Argon2 password hash and 476 proof-of-work function", Work in Progress, Internet-Draft, 477 draft-irtf-cfrg-argon2-10, 25 March 2020, 478 . 480 [NISTSP132] 481 Turan, M., Barker, E., Burr, W., and L. Chen, 482 "Recommendation for Password-Based Key Derivation Part 1: 483 Storage Applications", NIST Special Publication SP 484 800-132, DOI 10.6028/NIST.SP.800-132, December 2010, 485 . 488 [NISTSP63-3] 489 Grassi, P., Garcia, M., and J. Fenton, "Digital Identity 490 Guidelines", NIST Special Publication SP 800-63-3, 491 DOI 10.6028/NIST.SP.800-63-3, June 2017, 492 . 495 [NISTSP63b] 496 Grassi, P., Fenton, J., Newton, E., Perlner, R., 497 Regenscheid, A., Burr, W., Richer, J., Lefkovitz, N., 498 Danker, J., Choong, Y., Greene, K., and M. Theofanos, 499 "Digital Identity Guidelines: Authentication and Lifecycle 500 Management", NIST Special Publication SP 800-63b, 501 DOI 10.6028/NIST.SP.800-63b, June 2017, 502 . 505 [OWASP.CS.passwords] 506 Manico, J., Saad, E., Maćkowski, J., and R. Bailey, 507 "Password Storage", OWASP Cheat Sheet Password Storage, 508 April 2020, 509 . 512 [RFC4422] Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple 513 Authentication and Security Layer (SASL)", RFC 4422, 514 DOI 10.17487/RFC4422, June 2006, 515 . 517 [RFC5802] Newman, C., Menon-Sen, A., Melnikov, A., and N. Williams, 518 "Salted Challenge Response Authentication Mechanism 519 (SCRAM) SASL and GSS-API Mechanisms", RFC 5802, 520 DOI 10.17487/RFC5802, July 2010, 521 . 523 [RFC6331] Melnikov, A., "Moving DIGEST-MD5 to Historic", RFC 6331, 524 DOI 10.17487/RFC6331, July 2011, 525 . 527 [RFC7677] Hansen, T., "SCRAM-SHA-256 and SCRAM-SHA-256-PLUS Simple 528 Authentication and Security Layer (SASL) Mechanisms", 529 RFC 7677, DOI 10.17487/RFC7677, November 2015, 530 . 532 [RFC7914] Percival, C. and S. Josefsson, "The scrypt Password-Based 533 Key Derivation Function", RFC 7914, DOI 10.17487/RFC7914, 534 August 2016, . 536 [RFC8018] Moriarty, K., Ed., Kaliski, B., and A. Rusch, "PKCS #5: 537 Password-Based Cryptography Specification Version 2.1", 538 RFC 8018, DOI 10.17487/RFC8018, January 2017, 539 . 541 [RFC8264] Saint-Andre, P. and M. Blanchet, "PRECIS Framework: 542 Preparation, Enforcement, and Comparison of 543 Internationalized Strings in Application Protocols", 544 RFC 8264, DOI 10.17487/RFC8264, October 2017, 545 . 547 [RFC8265] Saint-Andre, P. and A. Melnikov, "Preparation, 548 Enforcement, and Comparison of Internationalized Strings 549 Representing Usernames and Passwords", RFC 8265, 550 DOI 10.17487/RFC8265, October 2017, 551 . 553 [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol 554 Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, 555 . 557 [SCRYPT] Percival, C., "Stronger key derivation via sequential 558 memory-hard functions", 559 BSDCan'09 http://www.tarsnap.com/scrypt/scrypt.pdf, May 560 2009. 562 Appendix A. Acknowledgments 564 The author would like to thank the civil servants at the National 565 Institute of Standards and Technology for their work on the Special 566 Publications series. U.S. executive agencies are an undervalued 567 national treasure, and they deserve our thanks. 569 Thanks also to Cameron Paul and Thomas Copeland for their reviews and 570 suggestions. 572 Author's Address 574 Sam Whited 575 Atlanta, GA 576 United States of America 578 Email: sam@samwhited.com 579 URI: https://blog.samwhited.com/