Security issue: deletion token persists too long and is stored in plain text instead of being hashed. #522

Closed
opened 2026-03-13 07:50:53 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @JosipPardon on GitHub (Jan 4, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Follow setup for user deletion from docs.

Current vs. Expected behavior

The generated user deletion token lasts for 24 hours, and there is no option to change it. I think this duration is too long and insecure. The default expiry time should be much shorter and configurable to a custom value.

Also, why values in verification table are not hashed? Like OTPs and deletion tokens. They are stored as plain text, which seems very insecure to me.


Even though this is a security issue, I decided to post it publicly because it is not critical (attackers cannot use it directly to harm existing apps). Also, there is a similar publicly posted issue about security that was neither commented on nor closed for around three days, so I wanted to continue the discussion about this.

Originally created by @JosipPardon on GitHub (Jan 4, 2025). ### Is this suited for github? - [X] Yes, this is suited for github ### To Reproduce Follow setup for user deletion from [docs](https://www.better-auth.com/docs/concepts/users-accounts#adding-verification-before-deletion). ### Current vs. Expected behavior The generated user deletion token lasts for 24 hours, and there is no option to change it. I think this duration is too long and insecure. The default expiry time should be much shorter and configurable to a custom value. Also, why values in verification table are not hashed? Like OTPs and deletion tokens. They are stored as plain text, which seems very insecure to me. *** Even though this is a security issue, I decided to post it publicly because it is not critical (attackers cannot use it directly to harm existing apps). Also, there is a similar publicly posted [issue](https://github.com/better-auth/better-auth/issues/1093) about security that was neither commented on nor closed for around three days, so I wanted to continue the discussion about this.
GiteaMirror added the bug label 2026-03-13 07:50:53 -05:00
Author
Owner

@Bekacru commented on GitHub (Jan 4, 2025):

Making the deletion token expiry time configurable is a good suggestion, and it’s something we should consider. That said, 24 hours is a solid default, it reduces the chances of users needing to request multiple tokens and allows time for any back-and-forth communication if needed.

As for hashing OTP values, it doesn’t provide meaningful protection but does introduce significant overhead. In particular, using strong hashing algos could make it impractical to support certain features in edge/worker envs with limited CPU time. hahsing is mainly important for passwords and other values because they can be reused outside your system. But, if your database is already breached, hashing these values won’t add meaningful protection or reduce the attack surface. that said, we should consider adding optional hashing for those who need it.

@Bekacru commented on GitHub (Jan 4, 2025): Making the deletion token expiry time configurable is a good suggestion, and it’s something we should consider. That said, 24 hours is a solid default, it reduces the chances of users needing to request multiple tokens and allows time for any back-and-forth communication if needed. As for hashing OTP values, it doesn’t provide meaningful protection but does introduce significant overhead. In particular, using strong hashing algos could make it impractical to support certain features in edge/worker envs with limited CPU time. hahsing is mainly important for passwords and other values because they can be reused outside your system. But, if your database is already breached, hashing these values won’t add meaningful protection or reduce the attack surface. that said, we should consider adding optional hashing for those who need it.
Author
Owner

@JosipPardon commented on GitHub (Jan 4, 2025):

@Bekacru Thanks for response. Yes, it would be great if we had these two things:

  1. Configurable expiry time for user deletion token
  2. Option to hash OTPs, tokens and other things in verification table

Thank you for putting so much effort into BetterAuth!

@JosipPardon commented on GitHub (Jan 4, 2025): @Bekacru Thanks for response. Yes, it would be great if we had these two things: 1) Configurable expiry time for user deletion token 2) Option to hash OTPs, tokens and other things in verification table Thank you for putting so much effort into BetterAuth!
Author
Owner

@dosubot[bot] commented on GitHub (Jun 13, 2025):

Hi, @JosipPardon. I'm Dosu, and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • You raised a security concern about user deletion tokens persisting for 24 hours without configurable expiry and being stored in plain text.
  • Bekacru acknowledged the suggestion for configurable expiry, noting the default is reasonable but flexibility could be beneficial.
  • Bekacru discussed the potential overhead of hashing tokens, suggesting it as an optional feature.
  • You reiterated the importance of configurable expiry and optional hashing for enhanced security.

Next Steps:

  • Please let me know if this issue is still relevant to the latest version of the better-auth repository. If so, you can keep the discussion open by commenting on the issue.
  • Otherwise, I will automatically close this issue in 7 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Jun 13, 2025): Hi, @JosipPardon. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - You raised a security concern about user deletion tokens persisting for 24 hours without configurable expiry and being stored in plain text. - Bekacru acknowledged the suggestion for configurable expiry, noting the default is reasonable but flexibility could be beneficial. - Bekacru discussed the potential overhead of hashing tokens, suggesting it as an optional feature. - You reiterated the importance of configurable expiry and optional hashing for enhanced security. **Next Steps:** - Please let me know if this issue is still relevant to the latest version of the better-auth repository. If so, you can keep the discussion open by commenting on the issue. - Otherwise, I will automatically close this issue in 7 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#522