Skip to content

user: PUT requires current_password for non-admins - #101

Open
aberoham wants to merge 2 commits into
NicTool:mainfrom
aberoham:user-current-password
Open

aberoham wants to merge 2 commits into
NicTool:mainfrom
aberoham:user-current-password

Conversation

@aberoham

Copy link
Copy Markdown
Contributor

PUT /user/{id} previously changed a password without checking the current password. Now a non-admin sending password must also send current_password, matching the target user's stored password. A missing current_password returns 400 with 'current password is required', and a wrong value returns 400 with 'current password is incorrect'. An unknown target id returns 404, as before. Admin status is read from the store on each request, not the session. An editor is an admin when is_admin is set and neither the editor nor their group is deleted. The route drops current_password before User.put, so the store never sees it.

The user store contract adds isAdmin(id) and checkPassword({ id, password }) on mysql, json and toml. The mongodb and elasticsearch stubs throw not yet implemented. checkPassword uses Credentials.validPassword and keys legacy HMAC SHA-1 hashes on the bare username, matching how they were written. It does not rewrite the hash.

This depends on NicTool/validate#36, which adds current_password to user.PUT. @nictool/validate 1.0.1 rejects the field with 400, so CI fails until validate releases. This PR bumps @nictool/validate to that release once it is out.

PUT /user/{id} changed a password without the current one. An editor
who is not a live admin must now send current_password, and it must
match the target user's stored password. Missing or wrong answers 400,
and the field never reaches the store.

isAdmin and checkPassword join the user store contract. isAdmin needs
the editor and their group live. checkPassword keys a legacy HMAC SHA-1
hash on the bare username, as the hash was written.
@msimerson

Copy link
Copy Markdown
Contributor

This is a feature I purposefully left out of NicTool 3. If the user has a login session, they already know the current password. This also presumes that passwords are the primary authentication means, but that's a short-term situation. Passkey support is more desirable.

@msimerson

Copy link
Copy Markdown
Contributor

To be clear, I'd support nuking the current password field entirely, in v2 and v3.

@aberoham

Copy link
Copy Markdown
Contributor Author

Dropping the password for passkeys, in v2 and v3, sounds good to me.

I'd still re-authenticate before any change to an authenticator, and passkeys don't change that. A login session is a bearer token. The web UI keeps the JWT in a cookie that page scripts can read, so an XSS or a shared machine hands it over. With that token alone, anyone can set a new password or add their own passkey, and keep the account after the token expires.

NIST SP 800-63B-4 sec. 4.1.2.1 covers binding a new authenticator. The process "requires authentication at either the maximum AAL currently available in the subscriber account or the maximum AAL at which the new authenticator will be used". OWASP ASVS 4.0.3 2.1.6 says the same for passwords: a password change requires the current and new password.

So I'd keep the check and make it method-neutral. Today the proof is the current password. Once passkeys land, a fresh passkey assertion satisfies it. I can reshape #101 that way.

@msimerson

Copy link
Copy Markdown
Contributor

OWASP ASVS 4.0.3 2.1.6 says the same for passwords: a password change requires the current and new password.

That may be, but it's almost never implemented. I find it annoying to use, especially with a password manager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants