Skip to content

Commit 2fe3bef

Browse files
docs(security): clarify password and authentication token storage
Assisted-by: Copilot:gpt-5.6-sol Signed-off-by: Josh <josh.t.richards@gmail.com>
1 parent 79d6ca8 commit 2fe3bef

1 file changed

Lines changed: 82 additions & 6 deletions

File tree

admin_manual/installation/harden_server.rst

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,91 @@ in a Linux environment.
1414

1515
Passwords
1616
---------
17-
Storage of access tokens
18-
^^^^^^^^^^^^^^^^^^^^^^^^
1917

20-
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+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20+
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.
27+
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.
31+
32+
This account-password hash is separate from any recoverable copy of the login
33+
password that Nextcloud may store in connection with authentication tokens, as
34+
described below.
2135

22-
Leakage of the access token can have negative security consequences. Depending on the data access by the actor, the risk here is different:
36+
Storage of authentication tokens
37+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38+
39+
After successful authentication, Nextcloud issues an authentication token that
40+
clients use for subsequent authenticated requests. Depending on the token type
41+
and client, the token may be transmitted in a session cookie, used as an app
42+
password, or sent as a bearer token. Anyone who obtains a valid token may be
43+
able to authenticate as the associated user, subject to the token's scope,
44+
expiration, type, and server-side validity checks.
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 should 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 the plaintext login
58+
password is available to Nextcloud, Nextcloud may store a reversibly encrypted
59+
copy of it in the server-side records associated with the user's authentication
60+
tokens. Consequently, for an account using the built-in database user backend,
61+
the database may contain both the one-way account-password hash described above
62+
and one or more separately encrypted, recoverable copies of the same password.
63+
64+
The authentication token itself does not contain the login password. For each
65+
token record, Nextcloud generates a separate RSA key pair. The login password
66+
is encrypted with the record's public key, while the corresponding private key
67+
is encrypted using the authentication token together with the
68+
instance-specific ``secret`` from ``config.php``. The token and instance secret
69+
are therefore required to decrypt the password stored in that token record.
70+
71+
The recoverable copy is used by features that require the login credentials,
72+
such as connecting to external storage, configuring mail accounts, and
73+
periodically checking whether the password remains valid. It is not stored
74+
when no password or equivalent user secret is available, as can occur with
75+
some SSO or passwordless authentication flows. Existing token records can also
76+
remain without a stored password until Nextcloud receives the password during
77+
a later login or password update.
78+
79+
Administrators can disable this behavior with
80+
``auth.storeCryptedPassword``. Disabling it does not affect the one-way
81+
account-password hash used by the built-in user backend, but features that
82+
require recovery of the login password may no longer work. Password changes
83+
made directly in an external user backend might also no longer automatically
84+
invalidate connected clients.
85+
86+
Security consequences
87+
^^^^^^^^^^^^^^^^^^^^^
2388

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.
89+
Leakage of authentication data can have negative security consequences. The
90+
impact depends on the data and capabilities available to the actor:
91+
92+
- An actor with access to only a valid authentication token can generally
93+
impersonate the associated user wherever that token is accepted. Access may
94+
be limited by the token's scope, expiration, type, and other validity checks.
95+
- An actor with access to an authentication token, the instance-specific
96+
``secret`` from ``config.php``, and the corresponding database record may be
97+
able to decrypt the login password stored in that record, if recoverable
98+
password storage was enabled and the password was available to Nextcloud.
99+
- Access to the one-way account-password hash alone does not provide a direct
100+
way to recover the password. However, password hashes must still be protected
101+
against offline password-guessing attacks.
26102

27103
Limit on password length
28104
^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)