-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Using Rails signed IDs is certainly an elegant way to go about account activations and password resets and 99.9% of the time I reckon they're fine in terms of security. However, it creates a single point of failure in the secret_key_base. Signed IDs are generated using the MessageVerifier API which is also used to generate signed cookies. Please see this blog post to understand what's going on under the hood:
https://binarysolo.chapter24.blog/demystifying-cookies-in-rails-6/#signed_cookies
If an app's secret_key_base becomes compromised due to whatever reason, it'll allow an attacker with access to this key to forge signed IDs and use them to reset the password for any account. (I'm also making an assumption the the salt hasn't been changed from the default but I can't imagine this is changed for the vast majority of Rails apps).
I'm not a security expert by any stretch of the imagination so I don't know how severe this risk is. I'd estimate it to be pretty low risk. However, just to avoid a single point of failure, I personally prefer to use a token stored securely using has_secure_password and then use the MessageVerifier API to generate the user facing token instead of using a bog standard signed ID.
This isn't to say the signed ID approach is "wrong" or "insecure" by any means. I'm just opening this issue to raise this potential flaw and have a chat about it :)