Skip to main content

Best practices for password hashing and storage
draft-whited-kitten-password-storage-00

The information below is for an old version of the document.
Document Type
This is an older version of an Internet-Draft whose latest revision state is "Replaced".
Author Sam Whited
Last updated 2020-04-28 (Latest revision 2020-04-23)
Replaced by draft-ietf-kitten-password-storage
RFC stream (None)
Formats
Additional resources
Stream Stream state (No stream defined)
Consensus boilerplate Unknown
RFC Editor Note (None)
IESG IESG state I-D Exists
Telechat date (None)
Responsible AD (None)
Send notices to (None)
draft-whited-kitten-password-storage-00
Common Authentication Technology Next Generation               S. Whited
Internet-Draft                                             21 April 2020
Intended status: Experimental                                           
Expires: 23 October 2020

            Best practices for password hashing and storage
                draft-whited-kitten-password-storage-00

Abstract

   This document outlines best practices for handling user passwords and
   other authenticator secrets in client-server systems making use of
   SASL.

Status of This Memo

   This Internet-Draft is submitted in full conformance with the
   provisions of BCP 78 and BCP 79.

   Internet-Drafts are working documents of the Internet Engineering
   Task Force (IETF).  Note that other groups may also distribute
   working documents as Internet-Drafts.  The list of current Internet-
   Drafts is at https://datatracker.ietf.org/drafts/current/.

   Internet-Drafts are draft documents valid for a maximum of six months
   and may be updated, replaced, or obsoleted by other documents at any
   time.  It is inappropriate to use Internet-Drafts as reference
   material or to cite them other than as "work in progress."

   This Internet-Draft will expire on 23 October 2020.

Copyright Notice

   Copyright (c) 2020 IETF Trust and the persons identified as the
   document authors.  All rights reserved.

   This document is subject to BCP 78 and the IETF Trust's Legal
   Provisions Relating to IETF Documents (https://trustee.ietf.org/
   license-info) in effect on the date of publication of this document.
   Please review these documents carefully, as they describe your rights
   and restrictions with respect to this document.  Code Components
   extracted from this document must include Simplified BSD License text
   as described in Section 4.e of the Trust Legal Provisions and are
   provided without warranty as described in the Simplified BSD License.

Whited                   Expires 23 October 2020                [Page 1]
Internet-DrafBest practices for password hashing and storage  April 2020

Table of Contents

   1.  Introduction  . . . . . . . . . . . . . . . . . . . . . . . .   2
     1.1.  Conventions and Terminology . . . . . . . . . . . . . . .   2
   2.  SASL Mechanisms . . . . . . . . . . . . . . . . . . . . . . .   3
   3.  Client Best Practices . . . . . . . . . . . . . . . . . . . .   3
     3.1.  Mechanism Pinning . . . . . . . . . . . . . . . . . . . .   3
     3.2.  Storage . . . . . . . . . . . . . . . . . . . . . . . . .   4
   4.  Server Best Practices . . . . . . . . . . . . . . . . . . . .   4
     4.1.  Additional SASL Requirements  . . . . . . . . . . . . . .   4
     4.2.  Storage . . . . . . . . . . . . . . . . . . . . . . . . .   4
     4.3.  Authentication and Rotation . . . . . . . . . . . . . . .   5
   5.  KDF Recommendations . . . . . . . . . . . . . . . . . . . . .   5
     5.1.  Argon2  . . . . . . . . . . . . . . . . . . . . . . . . .   5
     5.2.  Bcrypt  . . . . . . . . . . . . . . . . . . . . . . . . .   5
     5.3.  PBKDF2  . . . . . . . . . . . . . . . . . . . . . . . . .   6
     5.4.  Scrypt  . . . . . . . . . . . . . . . . . . . . . . . . .   6
   6.  Password Complexity Requirements  . . . . . . . . . . . . . .   7
   7.  Internationalization Considerations . . . . . . . . . . . . .   7
   8.  Security Considerations . . . . . . . . . . . . . . . . . . .   7
   9.  IANA Considerations . . . . . . . . . . . . . . . . . . . . .   8
   10. References  . . . . . . . . . . . . . . . . . . . . . . . . .   8
     10.1.  Normative References . . . . . . . . . . . . . . . . . .   8
     10.2.  Informative References . . . . . . . . . . . . . . . . .   8
   Appendix A.  Acknowledgments  . . . . . . . . . . . . . . . . . .  10
   Author's Address  . . . . . . . . . . . . . . . . . . . . . . . .  10

1.  Introduction

   Following best practices when hashing and storing passwords for use
   with SASL impacts a great deal more than just a users identity.  It
   also effects usability, and backwards compatibility by determining
   what authentication and authorization mechanisms can be used.

   Many of the recommendations in this document were taken from
   [NIST.SP.800-63b] and [NIST.SP.800-132].

1.1.  Conventions and Terminology

   Various security-related terms are to be understood in the sense
   defined in [RFC4949].  Some may also be defined in [NIST.SP.800-63-3]
   Appendix A.1 and in [NIST.SP.800-132] section 3.1.

   Throughout this document the term "password" is used to mean any
   password, passphrase, PIN, or other memorized secret.

Whited                   Expires 23 October 2020                [Page 2]
Internet-DrafBest practices for password hashing and storage  April 2020

   The term "pepper" is used to mean a secret added to a password hash
   like a salt.  Unlike a salt, peppers are secret, not unique, and are
   not stored alongside the hashed password.

   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
   "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
   "OPTIONAL" in this document are to be interpreted as described in BCP
   14 [RFC2119] [RFC8174] when, and only when, they appear in all
   capitals, as shown here.

2.  SASL Mechanisms

   For clients and servers that support password based authentication
   using [RFC4422] it is RECOMMENDED that the following SCRAM based
   mechanisms be implemented:

   *  SCRAM-SHA-256 ([RFC7677])

   *  SCRAM-SHA-256-PLUS ([RFC7677])

   System entities SHOULD NOT invent their own mechanisms that have not
   been standardized by the IETF or another reputable standards body.
   Similarly, entities SHOULD NOT implement any mechanism with a usage
   status of "OBSOLETE", "MUST NOT be used", or "LIMITED" in the IANA
   SASL Mechanisms Registry [IANA.sasl.mechanisms].

3.  Client Best Practices

3.1.  Mechanism Pinning

   Clients often maintain a list of preferred SASL mechanisms, generally
   ordered by perceived strength to enable strong authentication.  To
   prevent downgrade attacks by a malicious actor that has successfully
   man in the middled a connection, or compromised a trusted server's
   configuration, clients SHOULD implement "mechanism pinning".  That
   is, after the first successful authentication with a strong
   mechanism, clients SHOULD make a record of the authentication and
   thereafter only advertise and use mechanisms of equal or higher
   perceived strength.

   For reference, the following mechanisms are ordered by their
   perceived strength from strongest to weakest with mechanisms of equal
   strength on the same line.  This list is a non-normative example.  In
   particular this example does not imply that mechanisms in this list
   should or should not be supported.

   1.  EXTERNAL

Whited                   Expires 23 October 2020                [Page 3]
Internet-DrafBest practices for password hashing and storage  April 2020

   2.  SCRAM-SHA-1-PLUS, SCRAM-SHA-256-PLUS

   3.  SCRAM-SHA-1, SCRAM-SHA-256

   4.  PLAIN

   5.  DIGEST-MD5, CRAM-MD5

3.2.  Storage

   Clients SHOULD always store authenticators in a trusted and encrypted
   keystore such as the system keystore, or an encrypted store created
   specifically for the clients use.  They SHOULD NOT store
   authenticators as plain text.

   If clients know that they will only ever authenticate using a
   mechanism such as SCRAM where the original password is not needed
   (for example if the mechanism has been pinned) they SHOULD store the
   SCRAM bits or the hashed and salted password instead of the original
   password.  However, if backwards compatibility with servers that only
   support the PLAIN mechanism or other mechanisms that require using
   the original password is required, clients MAY choose to store the
   original password so long as an appropriate keystore is used.

4.  Server Best Practices

4.1.  Additional SASL Requirements

   Servers MUST NOT support any mechanism that would require
   authenticators to be stored in such a way that they could be
   recovered in plain text from the stored information.  This includes
   mechanisms that store authenticators using reversable encryption,
   obsolete hashing mechanisms such as MD5, and hashes that are
   unsuitable for use with authenticators such as SHA256.

4.2.  Storage

   Servers MUST always store passwords only after they have been salted
   and hashed.  If multiple hashes are supported for use with SCRAM, for
   example SCRAM-SHA-1 and SCRAM-SHA-256, separate salted and hashed
   passwords SHOULD be calculated and stored for each mechanism so that
   multiple clients that support only some of the mechanisms.

Whited                   Expires 23 October 2020                [Page 4]
Internet-DrafBest practices for password hashing and storage  April 2020

   A distinct salt SHOULD be used for each user, and each SCRAM family
   supported.  Salts MUST be generated using a cryptographically secure
   random number generator.  The salt MAY be stored in the same
   datastore as the password.  If it is stored alongside the password,
   it SHOULD be combined with a pepper stored in the application
   configuration, an environment variable, or some other location other
   than the datastore containing the salts.

4.3.  Authentication and Rotation

   When authenticating using PLAIN or similar mechanisms that involve
   transmitting the original password to the server the password MUST be
   hashed and compared against the salted and hashed password in the
   database using a constant time comparison.

   Each time a password is changed or reset, a new random salt MUST be
   created and the iteration count and pepper (if applicable) MUST be
   updated to the latest value required by server policy.

   If a pepper is used, consideration should be taken to ensure that it
   can be easily rotated.  For example, multiple peppers could be
   stored.  New passwords and reset passwords would use the newest
   papper and a hash of the pepper using a cryptographically secure hash
   function such as SHA256 could then be stored in the database next to
   the salt so that future logins can identify which pepper in the list
   was used.  This is just one example, pepper rotation schemes are
   outside the scope of this document.

5.  KDF Recommendations

   The recomendations in this section may change depending on the type
   of hardware being used and the security level required for the
   application.  With all Key Derivation Functions proper tuning is
   required to ensure that it meets the neds of the specific application
   or service.

5.1.  Argon2

   Argon2 [ARGON2ESP] is a winner of the Password Hashing Competition
   and has been recomended by OWASP for password hashing.

   Security considerations, test vectors, and parameters for tuning
   argon2 can be found in [I-D.irtf-cfrg-argon2].

5.2.  Bcrypt

   bcrypt [BCRYPT] is a Blowfish-based KDF that is the current OWASP
   recommendation for password hashing.

Whited                   Expires 23 October 2020                [Page 5]
Internet-DrafBest practices for password hashing and storage  April 2020

                    +-------------------------+-------+
                    |        Parameter        | Value |
                    +=========================+=======+
                    | Recommended Cost        | 12    |
                    +-------------------------+-------+
                    | Maximum Password Length | 64    |
                    +-------------------------+-------+

                         Table 1: Bcrypt Parameters

5.3.  PBKDF2

   PBKDF2 [RFC8018] is the key derivation function used by the SCRAM
   family of SASL mechanisms.

                   +-----------------------+----------+
                   |       Parameter       |  Value   |
                   +=======================+==========+
                   | Minimum Iterations    | 10,000   |
                   +-----------------------+----------+
                   | Minimum Salt Length   | 16 bytes |
                   +-----------------------+----------+
                   | Minimum Pepper Length | 32 bytes |
                   +-----------------------+----------+

                        Table 2: PBKDF2 Parameters

5.4.  Scrypt

   The [SCRYPT] key derivation function is designed to be memory-hard
   and sequential memory-hard to prevent against custom hardware based
   attacks.

   Security considerations, test vectors, and further notes on tuning
   scrypt may be found in [RFC7914].

                      +-----------+----------------+
                      | Parameter |     Value      |
                      +===========+================+
                      | N         | 32768 (N=2^15) |
                      +-----------+----------------+
                      | r         | 8              |
                      +-----------+----------------+
                      | p         | 1              |
                      +-----------+----------------+

                        Table 3: Scrypt Parameters

Whited                   Expires 23 October 2020                [Page 6]
Internet-DrafBest practices for password hashing and storage  April 2020

6.  Password Complexity Requirements

   Before any other password complexity requirements are checked, the
   preparation and enforcement steps of the OpaqueString profile of
   [RFC8265] SHOULD be applied (for more information see the
   Internationalization Considerations section).  Entities SHOULD
   enforce a minimum length of 8 characters for user passwords.  If
   using a mechanism such as PLAIN where the server performs hashing on
   the original password, a maximum length between 64 and 128 characters
   MAY be imposed to prevent denial of service (DoS) attacks.  Entities
   SHOULD NOT apply any other password restrictions.

   In addition to these password complexity requirements, servers SHOULD
   maintain a password blacklist and reject attempts by a claimant to
   use passwords on the blacklist during registration or password reset.
   The contents of this blacklist are a matter of server policy.  Some
   common recommendations include lists of common passwords that are not
   otherwise prevented by length requirements, passwords present in
   known breaches (when paired with the same email or other uniquely
   identifying information) to prevent reuse of compromised passwords,
   and password that match commonly used patterns such as "any single
   repeated character".

7.  Internationalization Considerations

   The PRECIS framework (Preparation, Enforcement, and Comparison of
   Internationalized Strings) defined in [RFC8264] is used to enforce
   internationalization rules on strings and to prevent common
   application security issues arrising from allowing the full range of
   Unicode codepoints in usernames, passwords, and other identifiers.
   The OpaqueString profile of [RFC8265] is used in this document to
   ensure that codepoints in passwords are treated carefully and
   consistently.  This ensures that users typing certain characters on
   different keyboards that may provide different versions of the same
   character will still be able to log in.  For example, some keyboards
   may output the full-width version of a character while other
   keyboards output the half-width version of the same character.  The
   Width Mapping rule of the OpaqueString profile addresses this and
   ensures that comparison succeeds and the claimant is able to be
   authenticated.

8.  Security Considerations

   This document contains recommendations that are likely to change over
   time.  It should be reviewed regularly to ensure that it remains
   accurate and up to date.  Many of the recommendations in this
   document were taken from the [OWASP.CS.passwords].

Whited                   Expires 23 October 2020                [Page 7]
Internet-DrafBest practices for password hashing and storage  April 2020

9.  IANA Considerations

   This document has no actions for IANA.

10.  References

10.1.  Normative References

   [IANA.sasl.mechanisms]
              IETF, "Simple Authentication and Security Layer (SASL)
              Mechanisms", November 2015,
              <https://www.iana.org/assignments/sasl-mechanisms/sasl-
              mechanisms.xhtml>.

   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
              Requirement Levels", BCP 14, RFC 2119,
              DOI 10.17487/RFC2119, March 1997,
              <https://www.rfc-editor.org/info/rfc2119>.

   [RFC4949]  Shirey, R., "Internet Security Glossary, Version 2",
              FYI 36, RFC 4949, DOI 10.17487/RFC4949, August 2007,
              <https://www.rfc-editor.org/info/rfc4949>.

   [RFC8174]  Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
              2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
              May 2017, <https://www.rfc-editor.org/info/rfc8174>.

10.2.  Informative References

   [ARGON2ESP]
              Biryukov, A., Dinu, D., and D. Khovratovich, "Argon2: New
              Generation of Memory-Hard Functions for Password Hashing
              and Other Applications", Euro SnP 2016, March 2016,
              <https://www.cryptolux.org/images/d/d0/Argon2ESP.pdf>.

   [BCRYPT]   Provos, N. and D. Mazières, "A Future-Adaptable Password
              Scheme", USENIX 1999
              https://www.usenix.org/legacy/event/usenix99/provos/
              provos.pdf, June 1999.

   [I-D.irtf-cfrg-argon2]
              Biryukov, A., Dinu, D., Khovratovich, D., and S.
              Josefsson, "The memory-hard Argon2 password hash and
              proof-of-work function", Work in Progress, Internet-Draft,
              draft-irtf-cfrg-argon2-10, 25 March 2020,
              <https://tools.ietf.org/html/draft-irtf-cfrg-argon2-10>.

Whited                   Expires 23 October 2020                [Page 8]
Internet-DrafBest practices for password hashing and storage  April 2020

   [NIST.SP.800-132]
              Turan, M., Barker, E., Burr, W., and L. Chen,
              "Recommendation for Password-Based Key Derivation Part 1:
              Storage Applications", NIST Special Publication SP
              800-132, DOI 10.6028/NIST.SP.800-132, December 2010,
              <https://nvlpubs.nist.gov/nistpubs/Legacy/SP/
              nistspecialpublication800-132.pdf>.

   [NIST.SP.800-63-3]
              Grassi, P., Garcia, M., and J. Fenton, "Digital Identity
              Guidelines", NIST Special Publication SP 800-63-3,
              DOI 10.6028/NIST.SP.800-63-3, June 2017,
              <https://nvlpubs.nist.gov/nistpubs/SpecialPublications/
              NIST.SP.800-63-3.pdf>.

   [NIST.SP.800-63b]
              Grassi, P., Fenton, J., Newton, E., Perlner, R.,
              Regenscheid, A., Burr, W., Richer, J., Lefkovitz, N.,
              Danker, J., Choong, Y., Greene, K., and M. Theofanos,
              "Digital Identity Guidelines: Authentication and Lifecycle
              Management", NIST Special Publication SP 800-63b,
              DOI 10.6028/NIST.SP.800-63b, June 2017,
              <https://nvlpubs.nist.gov/nistpubs/SpecialPublications/
              NIST.SP.800-63b.pdf>.

   [OWASP.CS.passwords]
              Manico, J., Saad, E., Maćkowski, J., and R. Bailey,
              "Password Storage", OWASP Cheat Sheet Password Storage,
              April 2020,
              <https://cheatsheetseries.owasp.org/cheatsheets/
              Password_Storage_Cheat_Sheet.html>.

   [RFC4422]  Melnikov, A., Ed. and K. Zeilenga, Ed., "Simple
              Authentication and Security Layer (SASL)", RFC 4422,
              DOI 10.17487/RFC4422, June 2006,
              <https://www.rfc-editor.org/info/rfc4422>.

   [RFC7677]  Hansen, T., "SCRAM-SHA-256 and SCRAM-SHA-256-PLUS Simple
              Authentication and Security Layer (SASL) Mechanisms",
              RFC 7677, DOI 10.17487/RFC7677, November 2015,
              <https://www.rfc-editor.org/info/rfc7677>.

   [RFC7914]  Percival, C. and S. Josefsson, "The scrypt Password-Based
              Key Derivation Function", RFC 7914, DOI 10.17487/RFC7914,
              August 2016, <https://www.rfc-editor.org/info/rfc7914>.

Whited                   Expires 23 October 2020                [Page 9]
Internet-DrafBest practices for password hashing and storage  April 2020

   [RFC8018]  Moriarty, K., Ed., Kaliski, B., and A. Rusch, "PKCS #5:
              Password-Based Cryptography Specification Version 2.1",
              RFC 8018, DOI 10.17487/RFC8018, January 2017,
              <https://www.rfc-editor.org/info/rfc8018>.

   [RFC8264]  Saint-Andre, P. and M. Blanchet, "PRECIS Framework:
              Preparation, Enforcement, and Comparison of
              Internationalized Strings in Application Protocols",
              RFC 8264, DOI 10.17487/RFC8264, October 2017,
              <https://www.rfc-editor.org/info/rfc8264>.

   [RFC8265]  Saint-Andre, P. and A. Melnikov, "Preparation,
              Enforcement, and Comparison of Internationalized Strings
              Representing Usernames and Passwords", RFC 8265,
              DOI 10.17487/RFC8265, October 2017,
              <https://www.rfc-editor.org/info/rfc8265>.

   [SCRYPT]   Percival, C., "Stronger key derivation via sequential
              memory-hard functions",
              BSDCan'09 http://www.tarsnap.com/scrypt/scrypt.pdf, May
              2009.

Appendix A.  Acknowledgments

   U.S. executive agencies are an undervalued national treasure, so the
   author would like to thank the civil servants at the National
   Institute of Standards and Technology for their work on the Special
   Publications series.

Author's Address

   Sam Whited
   Atlanta,  GA
   United States of America

   Email: sam@samwhited.com

Whited                   Expires 23 October 2020               [Page 10]