usememos / memos

An open-source, lightweight note-taking solution. The pain-less way to create your meaningful notes. Your Notes, Your Way.
https://usememos.com
MIT License
34.06k stars 2.47k forks source link

Passwords Limited to 72 Bytes #3779

Closed starsoccer closed 2 months ago

starsoccer commented 3 months ago

Describe the bug

It seems currently passwords are limited to 72 bytes for no clear reason. Instead passwords of any length should be allowed or atleast 128+

Steps to reproduce

  1. Create a new Memos Instance
  2. When prompted to enter a password enter a 100 character password
  3. Error appears saying passwords are limited to 72 bytes

The version of Memos you're using.

stable

Screenshots or additional context

No response

michaeldakin commented 3 months ago

I believe this is a limitation with bcrypt's 'GenerateFromPassword' function which has a max limit of 72 bits.

From the docs it states: ''' GenerateFromPassword does not accept passwords longer than 72 bytes, which is the longest password bcrypt will operate on.'''

May be worth reviewing something like argon2id to allow longer passwords?

Other reading:

wsw70 commented 3 months ago

Bcrypt is outdated

OWASP Password Storage Cheat Sheet recommends

Argon2id is a no-brainer today (well, until the next best solutions arrive :)) and has a native implementation in Go


Note: I would not say that this issue is a "bug", but rather an improvement (this is to address the bug label

starsoccer commented 3 months ago

Well if changing to not use bcrypt is not an option, another option is to just hash the password before passing to bcrypt and then using that hash as the actual input. This seems to be common too.