Cloudflare Workers caps PBKDF2 at 100,000 iterations. Node doesn't. wrangler dev doesn't. So a local benchmark and a full end-to-end migration test both passed — and production broke in a way nobody could see.

1 points•hansreno•8 days ago•3 comments•

3 comments

kentonv8 days ago
Sorry, this is a bug.

It dates back to when Workers only supported 50ms CPU time limits. Back then 100k iterations was enough to exceed the 50ms budget.

Now that the limit is 5 minutes this is pretty silly, but since PBKDF2 is considered obsolete and not often used in new code, I guess fixing it never really came up.

I would accept a PR to increase the constant to 1M, or higher with a good argument (but most recommendations I see for iteration count are <1M). Constant defined here:

https://github.com/cloudflare/workerd/blob/main/src/workerd/...

OhMeadhbh7 days ago
Alas. Some people cannot use Argon2id due to regulatory or corporate policy reasons. NIST SP 800-132 hasn't received any love since 2010, so it's understandable it's not on the list of "approved" algorithms. The people involved in the "Password Hashing Competition" seem like serious people (I noticed Peter Gutmann and Matthew Green's names attached) but I suspect NIST really wants to see an "official" selection competition with plenty of NSA spooks given the opportunity to weigh in. The flip side is after the Dual_EC_DRBG kerfuffle, it's hard to imagine too many people wanting NSA in the room at such meetings.

Which is to say... yes... I would probably use Argon2id if I could, but I can't (I mean... not in all projects) so fixing this bug is appreciated.

kentonv8 days ago
Also FWIW I've had success with argon2 in workers via wasm.

Read the full thread on Hacker News →

Related stories