8000 couch-auth session validation fails on valid sessions - CouchDB > v3.4 · Issue #100 · perfood/couch-auth · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

couch-auth session validation fails on valid sessions - CouchDB > v3.4 #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
chrispahm opened this issue May 25, 2025 · 0 comments
Open

Comments

@chrispahm
Copy link

CouchDB > 3.4 moved from SHA-1 to PBKDF2 with SHA-256 for password hashing as a default (see apache/couchdb#4814 and https://docs.couchdb.org/en/stable/whatsnew/3.4.html). Also the default iteration count increased to 600000, and the new key length is 32.

As a result, new sessions issued by CouchDB are always considered invalid by couch-auth, since there is a digest, iteration and key length mismatch. Among others, this affects all endpoints using middleware auch as requireAuth.

To make things more complicated, CouchDB allows both legacy SHA-1 sessions and SHA-256 sessions in the _users DB for the time being. I'm no expert on the CouchDB internals, but the way I understand it both types need to be supported for now (even though SHA-1 is considered deprecated).

I wrote a quick and naïve hotfix that creates two couch-pwd instances in hashing.ts, one with the legacy and one with the new defaults. The naïve implementations uses the iterations property of the hash_object to determine which couch-pwd instance to use. The hotfix won't work for custom iterations settings, and is only tested for user login and session validation. Also, it doesn't include a hash cache similar to CouchDB, so validation takes (too) long given the high iteration count. In any way, it's not really suitable for a PR, and was solely made to fix prod (note to self: don't ever do a minor CouchDB update on a friday afternoon) 🤷‍♂

In any way, I'm open for better ideas of how to implement the new password hashing strategy!

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

No branches or pull requests

1 participant
0