You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upon successful authentication, Nextcloud issues an access token that clients will use for all future HTTP requests. This access token uniquely identifies a user and should not be stored on any system other than the client requesting it. The user password is also stored encrypted in the Nextcloud database. For encryption of the password, the token and an instance-specific secret is used.
18
+
Storage of account passwords
19
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
21
20
22
-
Leakage of the access token can have negative security consequences. Depending on the data access by the actor, the risk here is different:
21
+
Nextcloud's built-in database user backend stores a salted, one-way hash of
22
+
each account password. It prefers Argon2id (when supported by the PHP
23
+
installation), with Argon2i and bcrypt used as fallbacks. The algorithm, salt,
24
+
and cost parameters are included in the stored hash. Existing hashes are
25
+
automatically upgraded following successful password verification when they no
26
+
longer match the preferred algorithm or parameters.
23
27
24
-
- An actor with access to only the access token can impersonate users and login as them.
25
-
- An actor with access to the access token, the Nextcloud config file, and the Nextcloud database can decrypt user passwords stored in the database.
28
+
The hash is used to verify password-based login attempts and is not designed
29
+
to be decrypted. When an external user backend (such as LDAP) is used, storage
30
+
and verification of the account password are controlled by that backend.
26
31
27
-
Limit on password length
28
-
^^^^^^^^^^^^^^^^^^^^^^^^
32
+
This account-password hash is separate from any recoverable copy of the login
33
+
password that Nextcloud stores in connection with authentication tokens, as
34
+
described below.
35
+
36
+
Storage of authentication tokens
37
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38
+
39
+
After successful authentication, Nextcloud issues an authentication token that
40
+
the client presents with subsequent authenticated requests. A valid token can
41
+
authenticate as the associated user, subject to the token's scope, expiration,
42
+
type, and server-side validity checks. Depending on the token type and client,
43
+
the token may be transmitted in a session cookie, used as an app password, or
44
+
sent as a bearer token.
45
+
46
+
Nextcloud does not store the plaintext authentication token in the database.
47
+
Instead, it stores a SHA-512 hash derived from the token and the
48
+
instance-specific ``secret``. The corresponding server-side token record
49
+
contains the associated user identity, authentication metadata, and
50
+
cryptographic key material. Authentication tokens must therefore be
51
+
protected like passwords. They should not be logged, placed in URLs, or
52
+
intentionally persisted outside the client that uses them.
53
+
54
+
Token-associated storage of login passwords
55
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
56
+
57
+
By default, ``auth.storeCryptedPassword`` is enabled. When this setting is
58
+
enabled and the login password is available during token creation, Nextcloud
59
+
stores a reversibly encrypted copy of it in the server-side
60
+
authentication-token record.
61
+
62
+
For an account using the built-in database user backend, this encrypted copy is
63
+
separate from the one-way account-password hash. The database contains the
64
+
one-way account-password hash and also contains an encrypted password copy for
65
+
each authentication-token record created with password storage enabled and a
66
+
login password supplied.
67
+
68
+
The recoverable copy is used by features that need the original login
69
+
credentials, such as connecting to external storage, autoconfiguring accounts
70
+
in the Mail app, and periodically checking whether the login credentials
71
+
remain valid. When token creation receives no login password, the resulting
72
+
token record contains no recoverable password. Such a token record remains
73
+
without a stored password until Nextcloud receives the password during a later
74
+
login or password update.
75
+
76
+
The authentication token itself does not contain the login password. Each
77
+
token record has a separate RSA key pair. Nextcloud encrypts the login password
78
+
with the record's public key and encrypts the corresponding private key using
79
+
the authentication token together with the instance-specific ``secret`` from
80
+
``config.php``. Possession of the authentication token, instance secret, and
81
+
corresponding database record is therefore sufficient to decrypt a password
82
+
stored in that record.
83
+
84
+
Administrators can disable this behavior with ``auth.storeCryptedPassword``.
85
+
Disabling it does not affect the one-way account-password hash used by the
86
+
built-in database user backend. Features that rely on recovering the login
87
+
password from an authenticate-token record cannot retrieve it from records
88
+
created without a stored password.
89
+
90
+
When an authentication token contains a stored password, Nextcloud periodically
91
+
checks that password against the user backend. If the password is no longer
92
+
valid, Nextcloud marks the token as having an invalid password and rejects
93
+
authentication with that token. When the token contains no stored password,
94
+
Nextcloud skips this password check. Consequently, changing a password directly
95
+
in an external user backend does not cause a token without a stored password
96
+
to be rejected through the periodic credential check. The password change
97
+
alone does not invalidate the token; the token remains valid until it expires,
98
+
is otherwise invalidated, or the user is disabled.
99
+
100
+
Security consequences
101
+
^^^^^^^^^^^^^^^^^^^^^
29
102
30
-
Nextcloud uses the bcrypt algorithm, and thus for security and performance
31
-
reasons, e.g. Denial of Service as CPU demand increases exponentially, it only
32
-
verifies the first 72 characters of passwords. This applies to all passwords
33
-
that you use in Nextcloud: user passwords, passwords on link shares, and
34
-
passwords on external shares.
103
+
Leakage of authentication data has the following security consequences:
104
+
105
+
- An actor with a valid authentication token can authenticate as the associated
106
+
user, subject to the token's scope, expiration, type, and server-side validity
107
+
checks.
108
+
- An actor with the authentication token, the instance-specific ``secret`` from
109
+
``config.php``, and the corresponding database record can decrypt the login
110
+
password stored in that record.
111
+
- An account-password hash does not reveal the original password directly, but
112
+
an actor who obtains it can perform offline password-guessing attacks.
113
+
114
+
.. _password_length_limits:
115
+
116
+
Password Length Limits
117
+
^^^^^^^^^^^^^^^^^^^^^^
118
+
119
+
Nextcloud accepts account passwords of up to 469 bytes through its standard
120
+
account-creation, password-change, and password-reset interfaces. This is the
121
+
maximum account-password length enforced by these interfaces. Because the
122
+
limit is measured in bytes, a password containing multibyte characters (such as
123
+
emojis or characters from non-Latin scripts) can reach the limit with fewer
124
+
than 469 characters.
125
+
126
+
Administrators can use the
127
+
:doc:`Password Policy app </configuration_user/user_password_policy>` to
128
+
configure requirements such as a minimum password length and other complexity
129
+
rules. External user backends can impose additional or different requirements.
130
+
131
+
The following implementation details do not change the 469-byte
132
+
account-password maximum, but are relevant when selecting a password policy:
133
+
134
+
Token Encryption Performance
135
+
When ``auth.storeCryptedPassword`` is enabled and an account password is
136
+
longer than 214 bytes, Nextcloud uses a larger RSA key when creating
137
+
authentication-token records. This increases token-generation overhead, but
138
+
does not prevent passwords between 215 and 469 bytes from being accepted.
139
+
The 214-byte threshold is therefore a performance consideration, not a
140
+
password-length limit.
141
+
142
+
Administrators who expect very long or one-time passwords to be used may
143
+
consider disabling ``auth.storeCryptedPassword`` to avoid this overhead,
144
+
subject to the functional consequences described above.
145
+
146
+
Algorithmic Truncation (bcrypt fallback)
147
+
Nextcloud prefers Argon2id for one-way password hashing (when supported
148
+
by the PHP installation), with Argon2i and bcrypt as fallbacks. Bcrypt
149
+
considers only the first 72 bytes of its input. Therefore, if bcrypt is
150
+
selected, input after the first 72 bytes does not contribute to password
151
+
verification. This is a bcrypt-specific behavior, not a general 72-byte
152
+
limit imposed by Nextcloud.
153
+
154
+
Passwords protecting public link and mail shares use the same one-way password
155
+
hasher and are subject to the applicable share-password policy. They are not
156
+
stored in authentication-token records, so the encryption-related performance
0 commit comments