draft-ietf-kitten-password-storage-04.txt   draft-ietf-kitten-password-storage-05.txt 
Common Authentication Technology Next Generation S. Whited Common Authentication Technology Next Generation S. Whited
Internet-Draft 18 March 2021 Internet-Draft 1 April 2021
Intended status: Best Current Practice Intended status: Best Current Practice
Expires: 19 September 2021 Expires: 3 October 2021
Best practices for password hashing and storage Best practices for password hashing and storage
draft-ietf-kitten-password-storage-04 draft-ietf-kitten-password-storage-05
Abstract Abstract
This document outlines best practices for handling user passwords and This document outlines best practices for handling user passwords and
other authenticator secrets in client-server systems making use of other authenticator secrets in client-server systems making use of
SASL. SASL.
Status of This Memo Status of This Memo
This Internet-Draft is submitted in full conformance with the This Internet-Draft is submitted in full conformance with the
skipping to change at page 1, line 32 skipping to change at page 1, line 32
Internet-Drafts are working documents of the Internet Engineering Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet- working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/. Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress." material or to cite them other than as "work in progress."
This Internet-Draft will expire on 19 September 2021. This Internet-Draft will expire on 3 October 2021.
Copyright Notice Copyright Notice
Copyright (c) 2021 IETF Trust and the persons identified as the Copyright (c) 2021 IETF Trust and the persons identified as the
document authors. All rights reserved. document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents (https://trustee.ietf.org/ Provisions Relating to IETF Documents (https://trustee.ietf.org/
license-info) in effect on the date of publication of this document. license-info) in effect on the date of publication of this document.
Please review these documents carefully, as they describe your rights Please review these documents carefully, as they describe your rights
skipping to change at page 2, line 24 skipping to change at page 2, line 24
4.1. Additional SASL Requirements . . . . . . . . . . . . . . 5 4.1. Additional SASL Requirements . . . . . . . . . . . . . . 5
4.2. Storage . . . . . . . . . . . . . . . . . . . . . . . . . 5 4.2. Storage . . . . . . . . . . . . . . . . . . . . . . . . . 5
4.3. Authentication and Rotation . . . . . . . . . . . . . . . 6 4.3. Authentication and Rotation . . . . . . . . . . . . . . . 6
5. KDF Recommendations . . . . . . . . . . . . . . . . . . . . . 6 5. KDF Recommendations . . . . . . . . . . . . . . . . . . . . . 6
5.1. Argon2 . . . . . . . . . . . . . . . . . . . . . . . . . 7 5.1. Argon2 . . . . . . . . . . . . . . . . . . . . . . . . . 7
5.2. Bcrypt . . . . . . . . . . . . . . . . . . . . . . . . . 7 5.2. Bcrypt . . . . . . . . . . . . . . . . . . . . . . . . . 7
5.3. PBKDF2 . . . . . . . . . . . . . . . . . . . . . . . . . 7 5.3. PBKDF2 . . . . . . . . . . . . . . . . . . . . . . . . . 7
5.4. Scrypt . . . . . . . . . . . . . . . . . . . . . . . . . 8 5.4. Scrypt . . . . . . . . . . . . . . . . . . . . . . . . . 8
6. Password Complexity Requirements . . . . . . . . . . . . . . 9 6. Password Complexity Requirements . . . . . . . . . . . . . . 9
7. Internationalization Considerations . . . . . . . . . . . . . 9 7. Internationalization Considerations . . . . . . . . . . . . . 9
8. Security Considerations . . . . . . . . . . . . . . . . . . . 9 8. Security Considerations . . . . . . . . . . . . . . . . . . . 10
9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 10 9. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 10
10. References . . . . . . . . . . . . . . . . . . . . . . . . . 10 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 10
10.1. Normative References . . . . . . . . . . . . . . . . . . 10 10.1. Normative References . . . . . . . . . . . . . . . . . . 10
10.2. Informative References . . . . . . . . . . . . . . . . . 11 10.2. Informative References . . . . . . . . . . . . . . . . . 11
Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 13 Appendix A. Acknowledgments . . . . . . . . . . . . . . . . . . 13
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 13 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 13
1. Introduction 1. Introduction
Following best practices when hashing and storing passwords for use Following best practices when hashing and storing passwords for use
skipping to change at page 3, line 12 skipping to change at page 3, line 12
Mechanism pinning A security mechanism which allows SASL clients to Mechanism pinning A security mechanism which allows SASL clients to
resist downgrade attacks. Clients that implement mechanism resist downgrade attacks. Clients that implement mechanism
pinning remember the perceived strength of the SASL mechanism used pinning remember the perceived strength of the SASL mechanism used
in a previous successful authentication attempt and thereafter in a previous successful authentication attempt and thereafter
only authenticate using mechanisms of equal or higher perceived only authenticate using mechanisms of equal or higher perceived
strength. strength.
Pepper A secret added to a password hash like a salt. Unlike a Pepper A secret added to a password hash like a salt. Unlike a
salt, peppers are secret and the same pepper may be reused for salt, peppers are secret and the same pepper may be reused for
many hashed passwords. They must not be stored alongside the many hashed passwords. They MUST NOT be stored alongside the
hashed password. hashed password.
Salt In this document salt is used as defined in [RFC4949]. Salt In this document salt is used as defined in [RFC4949].
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
"OPTIONAL" in this document are to be interpreted as described in BCP "OPTIONAL" in this document are to be interpreted as described in BCP
14 [RFC2119] [RFC8174] when, and only when, they appear in all 14 [RFC2119] [RFC8174] when, and only when, they appear in all
capitals, as shown here. capitals, as shown here.
skipping to change at page 4, line 9 skipping to change at page 4, line 9
security layer. Because of this a strong security layer such as TLS security layer. Because of this a strong security layer such as TLS
[RFC8446] MUST be negotiated before SASL mechanisms can be advertised [RFC8446] MUST be negotiated before SASL mechanisms can be advertised
or negotiated. or negotiated.
3. Client Best Practices 3. Client Best Practices
3.1. Mechanism Pinning 3.1. Mechanism Pinning
Clients often maintain a list of preferred SASL mechanisms, generally Clients often maintain a list of preferred SASL mechanisms, generally
ordered by perceived strength to enable strong authentication. To ordered by perceived strength to enable strong authentication. To
prevent downgrade attacks by a malicious actor that has successfully prevent downgrade attacks by a malicious actor that has successfully
man in the middled a connection, or compromised a trusted server's executed an in-the-middle attack on a connection, or compromised a
configuration, clients SHOULD implement "mechanism pinning". That trusted server's configuration, clients SHOULD implement "mechanism
is, after the first successful authentication with a strong pinning". That is, after the first successful authentication with a
mechanism, clients SHOULD make a record of the authentication and strong mechanism, clients SHOULD make a record of the authentication
thereafter only advertise and use mechanisms of equal or higher and thereafter only advertise and use mechanisms of equal or higher
perceived strength. perceived strength.
The following mechanisms are ordered by their perceived strength from The following mechanisms are ordered by their perceived strength from
strongest to weakest with mechanisms of equal strength on the same strongest to weakest with mechanisms of equal strength on the same
line. The remainder of this section is merely informative. In line. The remainder of this section is merely informative. In
particular this example does not imply that mechanisms in this list particular this example does not imply that mechanisms in this list
should or should not be implemented. should or should not be implemented.
1. EXTERNAL 1. EXTERNAL
skipping to change at page 5, line 7 skipping to change at page 5, line 7
Finally, the PLAIN mechanism sends the username and password in plain Finally, the PLAIN mechanism sends the username and password in plain
text and therefore requires a strong security layer such as TLS for text and therefore requires a strong security layer such as TLS for
the password to be protected in transit. However, if the server is the password to be protected in transit. However, if the server is
trusted to know the password PLAIN does allow for the use of a strong trusted to know the password PLAIN does allow for the use of a strong
key derivation function (KDF) for storing the authentication data at key derivation function (KDF) for storing the authentication data at
rest and provides for password hash agility. rest and provides for password hash agility.
3.2. Storage 3.2. Storage
Clients SHOULD always store authenticators in a trusted and encrypted Clients SHOULD always store authentication secrets in a trusted and
keystore such as the system keystore, or an encrypted store created encrypted keystore such as the system keystore, or an encrypted store
specifically for the clients use. They SHOULD NOT store created specifically for the clients use. They SHOULD NOT store
authenticators as plain text. authentication secrets as plain text.
If clients know that they will only ever authenticate using a If clients know that they will only ever authenticate using a
mechanism such as SCRAM [RFC5802] where the original password is not mechanism such as SCRAM [RFC5802] where the original password is not
needed after the first authentication attempt they SHOULD store the needed after the first authentication attempt they SHOULD store the
SCRAM bits or the hashed and salted password instead of the original SCRAM bits or the hashed and salted password instead of the original
password. However, if backwards compatibility with servers that only password. However, if backwards compatibility with servers that only
support the PLAIN mechanism or other mechanisms that require using support the PLAIN mechanism or other mechanisms that require using
the original password is required, clients MAY choose to store the the original password is required, clients MAY choose to store the
original password so long as an appropriate keystore is used. original password so long as an appropriate keystore is used.
4. Server Best Practices 4. Server Best Practices
4.1. Additional SASL Requirements 4.1. Additional SASL Requirements
Servers MUST NOT support any mechanism that would require Servers MUST NOT support any mechanism that would require
authenticators to be stored in such a way that they could be authentication secrets to be stored in such a way that they could be
recovered in plain text from the stored information. This includes recovered in plain text from the stored information. This includes
mechanisms that store authenticators using reversable encryption, mechanisms that store authentication secrets using reversable
obsolete hashing mechanisms such as MD5 or hashing mechanisms that encryption, obsolete hashing mechanisms such as MD5 or hashing
are cryptographically secure but designed for speed such as SHA256. mechanisms that are cryptographically secure but designed for speed
such as SHA256.
4.2. Storage 4.2. Storage
Servers MUST always store passwords only after they have been salted, Servers MUST always store passwords only after they have been salted,
peppered (if possible with the given authentication mechanism), and peppered (if possible with the given authentication mechanism), and
hashed using a strong KDF. A distinct salt SHOULD be used for each hashed using a strong KDF. A distinct salt SHOULD be used for each
user, and each SCRAM family supported. Salts SHOULD be generated user, and each SCRAM family supported. Salts SHOULD be generated
using a cryptographically secure random number generator. The salt using a cryptographically secure random number generator. The salt
MAY be stored in the same datastore as the password. A pepper stored MAY be stored in the same datastore as the password. A pepper stored
in the application configuration, or a secure location other than the in the application configuration, or a secure location other than the
datastore containing the salts, SHOULD be combined with the password datastore containing the salts, SHOULD be combined with the password
before hashing if possible with the given authentication mechanism. before hashing if possible with the given authentication mechanism.
Peppers SHOULD NOT be combined with the salt because the salt is not Peppers SHOULD NOT be combined with the salt because the salt is not
secret and may appear in the final hash output. secret and may appear in the final hash output.
The following restrictions MUST be observed when generating salts and The following restrictions MUST be observed when generating salts and
peppers, more up to date numbers may be found in peppers:
[OWASP.CS.passwords].
+=======================+==========+ +=======================+==========+
| Parameter | Value | | Parameter | Value |
+=======================+==========+ +=======================+==========+
| Minimum Salt Length | 16 bytes | | Minimum Salt Length | 4 bytes |
+-----------------------+----------+ +-----------------------+----------+
| Minimum Pepper Length | 32 bytes | | Minimum Pepper Length | 14 bytes |
+-----------------------+----------+ +-----------------------+----------+
Table 1: Common Parameters Table 1: Common Parameters
4.3. Authentication and Rotation 4.3. Authentication and Rotation
When authenticating using PLAIN or similar mechanisms that involve When authenticating using PLAIN or similar mechanisms that involve
transmitting the original password to the server the password MUST be transmitting the original password to the server the password MUST be
hashed and compared against the salted and hashed password in the hashed and compared against the salted and hashed password in the
database using a constant time comparison. database using a constant time comparison.
Each time a password is changed a new random salt MUST be created and Each time a password is changed a new random salt MUST be created and
the iteration count and pepper (if applicable) MUST be updated to the the iteration count and pepper (if applicable) MUST be updated to the
latest value required by server policy. latest value required by server policy.
If a pepper is used, consideration should be taken to ensure that it If a pepper is used, consideration should be taken to ensure that it
can be easily rotated. For example, multiple peppers could be can be easily rotated. For example, multiple peppers could be
stored. New passwords and reset passwords would use the newest stored. New passwords and reset passwords would use the newest
pepper and a hash of the pepper using a cryptographically secure hash pepper and a hash of the pepper using the same KDF that was used on
function such as SHA256 could then be stored in the database next to the password could then be stored in the database next to the salt so
the salt so that future logins can identify which pepper in the list that future logins can identify which pepper in the list was used.
was used. This is just one example, pepper rotation schemes are This is just one example, pepper rotation schemes are outside the
outside the scope of this document. scope of this document.
5. KDF Recommendations 5. KDF Recommendations
When properly configured, the following commonly used KDFs create When properly configured, the following commonly used KDFs create
suitable password hash results for server side storage. The suitable password hash results for server side storage. The
recommendations in this section may change depending on the hardware recommendations in this section may change depending on the hardware
being used and the security level required for the application. being used and the security level required for the application.
With all KDFs proper tuning is required to ensure that it meets the With all KDFs proper tuning is required to ensure that it meets the
needs of the specific application or service. For persistent login needs of the specific application or service. For persistent login
an iteration count or work factor that adds approximately a quarter an iteration count or work factor that adds approximately a quarter
of a second to login may be an acceptable tradeoff since logins are of a second to login may be an acceptable tradeoff since logins are
relatively rare. By contrast, verification tokens that are generated relatively rare. By contrast, verification tokens that are generated
many times per second may need to use a much lower work factor. many times per second may need to use a much lower work factor.
5.1. Argon2 5.1. Argon2
Argon2 [ARGON2ESP] is the 2015 winner of the Password Hashing Argon2 [ARGON2ESP] is the 2015 winner of the Password Hashing
Competition. Security considerations, test vectors, and parameters Competition and the current OWASP recommendation for password
for tuning argon2 can be found in [I-D.irtf-cfrg-argon2]. They are hashing. Security considerations, test vectors, and parameters for
copied here for easier reference. tuning argon2 can be found in [I-D.irtf-cfrg-argon2]. The defaults
are copied here for easier reference.
+==================================+==============+ +==================================+==============+
| Parameter | Value | | Parameter | Value |
+==================================+==============+ +==================================+==============+
| Degree of parallelism (p) | 1 | | Degree of parallelism (p) | 4 |
+----------------------------------+--------------+ +----------------------------------+--------------+
| Minimum memory size (m) | 32*1024 | | Minimum memory size (m) | 2 GiB |
+----------------------------------+--------------+ +----------------------------------+--------------+
| Minimum number of iterations (t) | 1 | | Minimum number of iterations (t) | 1 |
+----------------------------------+--------------+ +----------------------------------+--------------+
| Algorithm type (y) | Argon2id (2) | | Algorithm type (y) | Argon2id (2) |
+----------------------------------+--------------+ +----------------------------------+--------------+
| Minimum output length | 32 | | Minimum output length | 32 |
+----------------------------------+--------------+ +----------------------------------+--------------+
Table 2: Argon Parameters Table 2: Argon Parameters
5.2. Bcrypt 5.2. Bcrypt
bcrypt [BCRYPT] is a Blowfish-based KDF that is the current OWASP bcrypt [BCRYPT] is a Blowfish-based KDF.
recommendation for password hashing.
+=========================+=======================+ +=========================+=======================+
| Parameter | Value | | Parameter | Value |
+=========================+=======================+ +=========================+=======================+
| Recommended Cost | 12 | | Recommended Cost | 12 |
+-------------------------+-----------------------+ +-------------------------+-----------------------+
| Maximum Password Length | 50-72 bytes depending | | Maximum Password Length | 50-72 bytes depending |
| | on the implementation | | | on the implementation |
+-------------------------+-----------------------+ +-------------------------+-----------------------+
Table 3: Bcrypt Parameters Table 3: Bcrypt Parameters
5.3. PBKDF2 5.3. PBKDF2
PBKDF2 [RFC8018] is used by the SCRAM [RFC5802] family of SASL PBKDF2 [RFC8018] is used by the SCRAM [RFC5802] family of SASL
mechanisms. mechanisms.
+=============================+================================+ +=============================+================================+
| Parameter | Value | | Parameter | Value |
+=============================+================================+ +=============================+================================+
| Minimum iteration count (c) | 10,000 | | Minimum iteration count (c) | 310,000 |
+-----------------------------+--------------------------------+ +-----------------------------+--------------------------------+
| Hash | SHA256 | | Hash | HMAC-SHA256 |
+-----------------------------+--------------------------------+ +-----------------------------+--------------------------------+
| Output length (dkLen) | min(hLen, 32) (where hLen is | | Output length (dkLen) | min(hLen, 32) (where hLen is |
| | the length of the chosen hash) | | | the length of the chosen hash) |
+-----------------------------+--------------------------------+ +-----------------------------+--------------------------------+
Table 4: PBKDF2 Parameters Table 4: PBKDF2 Parameters
When PBKDF2 is used with HMAC such as in the SCRAM [RFC5802] family When PBKDF2 is used with HMAC such as in the SCRAM [RFC5802] family
of SASL mechanisms the password is pre-hashed if it is longer than of SASL mechanisms the password is pre-hashed if it is longer than
the block size of the hash function (hLen, or 64 bytes for SHA-256). the block size of the hash function (hLen, or 64 bytes for SHA-256).
skipping to change at page 9, line 43 skipping to change at page 9, line 43
ensure that codepoints in passwords are treated carefully and ensure that codepoints in passwords are treated carefully and
consistently. This ensures that users typing certain characters on consistently. This ensures that users typing certain characters on
different keyboards that may provide different versions of the same different keyboards that may provide different versions of the same
character will still be able to log in. For example, some keyboards character will still be able to log in. For example, some keyboards
may output the full-width version of a character while other may output the full-width version of a character while other
keyboards output the half-width version of the same character. The keyboards output the half-width version of the same character. The
Width Mapping rule of the OpaqueString profile addresses this and Width Mapping rule of the OpaqueString profile addresses this and
ensures that comparison succeeds and the claimant is able to be ensures that comparison succeeds and the claimant is able to be
authenticated. authenticated.
When enforcing a minimum password length the authentication server
SHOULD NOT count bytes as single Unicode scalar values may take up
many bytes. Similarly, a single emoji may be constructed from many
Unicode scalar values, so it may not be appropriate to count scalar
values or code points. Instead consider counting the number Grapheme
Clusters as defined in [UAX29].
8. Security Considerations 8. Security Considerations
This document contains recommendations that are likely to change over This document contains recommendations that are likely to change over
time. It should be reviewed regularly to ensure that it remains time. It should be reviewed regularly to ensure that it remains
accurate and up to date. Many of the recommendations in this accurate and up to date. Many of the recommendations in this
document were taken from [OWASP.CS.passwords], [NISTSP63b], and document were taken from [OWASP.CS.passwords], [NISTSP63b], and
[NISTSP132]. [NISTSP132].
The "-PLUS" variants of SCRAM [RFC5802] support channel binding to The "-PLUS" variants of SCRAM [RFC5802] support channel binding to
their underlying security layer, but lack a mechanism for negotiating their underlying security layer, but lack a mechanism for negotiating
skipping to change at page 13, line 26 skipping to change at page 13, line 31
[RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol [RFC8446] Rescorla, E., "The Transport Layer Security (TLS) Protocol
Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018, Version 1.3", RFC 8446, DOI 10.17487/RFC8446, August 2018,
<https://www.rfc-editor.org/info/rfc8446>. <https://www.rfc-editor.org/info/rfc8446>.
[SCRYPT] Percival, C., "Stronger key derivation via sequential [SCRYPT] Percival, C., "Stronger key derivation via sequential
memory-hard functions", memory-hard functions",
BSDCan'09 http://www.tarsnap.com/scrypt/scrypt.pdf, May BSDCan'09 http://www.tarsnap.com/scrypt/scrypt.pdf, May
2009. 2009.
[UAX29] Davis, M. and C. Chapman, "Unicode Text Segmentation",
February 2020, <https://www.unicode.org/reports/tr29/>.
Appendix A. Acknowledgments Appendix A. Acknowledgments
The author would like to thank the civil servants at the National The author would like to thank the civil servants at the National
Institute of Standards and Technology for their work on the Special Institute of Standards and Technology for their work on the Special
Publications series. U.S. executive agencies are an undervalued Publications series. U.S. executive agencies are an undervalued
national treasure, and they deserve our thanks. national treasure, and they deserve our thanks.
Thanks also to Cameron Paul and Thomas Copeland for their reviews and Thanks also to Cameron Paul and Thomas Copeland for their reviews and
suggestions. suggestions.
 End of changes. 22 change blocks. 
37 lines changed or deleted 47 lines changed or added

This html diff was produced by rfcdiff 1.48. The latest version is available from http://tools.ietf.org/tools/rfcdiff/