Page MenuHomePhabricator

[keyserver] Stop using bcrypt for session validation in new cookies
ClosedPublic

Authored by ashoat on Oct 19 2023, 1:44 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 10:19 PM
Unknown Object (File)
Wed, Nov 20, 5:14 PM
Unknown Object (File)
Wed, Nov 13, 4:21 AM
Unknown Object (File)
Wed, Nov 13, 4:21 AM
Unknown Object (File)
Wed, Nov 13, 4:21 AM
Unknown Object (File)
Wed, Nov 13, 4:21 AM
Unknown Object (File)
Wed, Nov 13, 4:21 AM
Unknown Object (File)
Wed, Oct 30, 6:52 AM
Subscribers

Details

Summary

Today about 50% of our keyserver CPU is used on session validation via bcrypt. This is very silly.

bcrypt is designed to be very CPU-expensive on purpose. It's designed that way to protect against dictionary attacks.

That sort of protection is absolutely unnecessary for our cookiePasswords, which are 32 random bytes. There is no dictionary attack against random strings.

To save CPU, while preserving the property that somebody with the MariaDB database can't forge a cookie, this diff moves us to store a simple sha256 hash in the database instead of a bcrypt hash.

Test Plan
  1. Make sure existing cookies still work by refreshing the web app in my local environment
  2. Create a new cookie by logging out and back in on web in my local environment. Refresh the page to make sure things still work

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable