In a web application that (as a side effect of implementing the password anti-pattern) stores passwords, one recommendation is to bcrypt to store them (or computationally expensive one-way salted hashes of them). However, doing this makes the server process spend most of its time doing CPU intensive bcrypt comparisons, since the whole point of using bcrypt is that it takes time to test a password.
My question is this: is it safe to cache (in-memory) the response of a bcrypt comparison? I'm not worried about spending the time once per process, but once for every single request will become a scalability bottleneck. Bonus points (?) if you can shed some light if it's common practice to do so.
Things I've considered:
- If it's in-memory only then it's harder to attack
- The persistent store is as secure as before if it's compromised
- Lowering the bcrypt load factor makes the password database more vulnerable, if compromised