我有一個帶有帳戶恢復流程的 Rails Nuxt 專案。
一種情況是用戶忘記了他注冊的電子郵件和密碼。用戶可以通過提交他的帳戶 ID 來記住他的電子郵件。Rails 然后用用戶的 id 和電子郵件的混淆版本進行回應。
此時,用戶已經知道他的電子郵件,但不知道他的密碼。于是他點擊了“記住密碼”按鈕。
默認情況下,Devise(auth 庫)期望提交完整的電子郵件(不是混淆的),以便生成恢復鏈接并將其發送給用戶。但此時,只有混淆的電子郵件可用,我不想打擾用戶填寫完整的電子郵件,因為我已經知道他是誰(從帳戶 ID)。
說到這里,我想知道為了通過使用用戶的 id 而不是電子郵件來發送恢復令牌,是否有一些關于覆寫下面設計的方法的安全問題?
# Attempt to find a user by its email. If a record is found, send new
# password instructions to it. If user is not found, returns a new user
# with an email not found error.
# Attributes must contain the user's email
def send_reset_password_instructions(attributes = {})
recoverable = find_or_initialize_with_errors(reset_password_keys, attributes, :not_found)
recoverable.send_reset_password_instructions if recoverable.persisted?
recoverable
end
https://github.com/heartcombo/devise/blob/main/lib/devise/models/recoverable.rb
uj5u.com熱心網友回復:
用戶名列舉等漏洞存在中等風險。帳戶 ID 往往比電子郵件地址更可預測,因此隨著用戶群的增長,有人濫用它來列舉帳戶的風險會增加。
您可以通過使用reCAPTCHA或要求已知資訊的其他因素,或兩者兼而有之,來減輕一些風險。
指出此功能與傳統重置功能之間的區別也很重要。重置功能可以通過對有效和無效電子郵件做出完全相同的回應來防止收集攻擊。例如:
If the email you provided is valid, a password reset link has been sent.
此恢復功能沒有這種能力。
uj5u.com熱心網友回復:
如果您最終將重置密碼發送到與資料庫中存在的用戶相關的電子郵件地址,我認為提供電子郵件或任何其他用戶 ID 之間的安全性沒有區別
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/391725.html
上一篇:HTML洗掉文本之間想要的空格
下一篇:我無法運行Rails服務器
