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)
Thu, Sep 26, 7:00 AM
Unknown Object (File)
Fri, Sep 20, 7:08 PM
Unknown Object (File)
Fri, Sep 20, 5:31 PM
Unknown Object (File)
Fri, Sep 20, 12:06 AM
Unknown Object (File)
Thu, Sep 19, 10:38 AM
Unknown Object (File)
Thu, Sep 19, 8:45 AM
Unknown Object (File)
Aug 28 2024, 2:28 PM
Unknown Object (File)
Aug 28 2024, 2:28 PM
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