-
Notifications
You must be signed in to change notification settings - Fork 1.9k
feat: implement threshold for resetting password #6035
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement threshold for resetting password #6035
Conversation
|
@uds5501 @mrsaicharan1 @kushthedude I'm not getting the time in the same format as it is getting stored in the db. For example, the time getting stored in db is - |
|
@shreyanshdwivedi We are not using pytz for time now , As recent change made by @prateekj117 we are now using |
Codecov Report
@@ Coverage Diff @@
## development #6035 +/- ##
===============================================
+ Coverage 66.12% 66.13% +0.01%
===============================================
Files 285 285
Lines 14089 14095 +6
===============================================
+ Hits 9316 9322 +6
Misses 4773 4773
Continue to review full report at Codecov.
|
niranjan94
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related comment: #6033 (comment)
Explore using https://flask-limiter.readthedocs.io/en/stable/ for this. That way we can extend it to other endpoints too.
|
@niranjan94 so should I use flask_limiter here rather than this approach for |
Yep. Correct. And the frontend can show an appropriate message to the user if it gets a |
|
@niranjan94 ok cool. But one thing, the issue mentioned -
But I don't think this type of message for a particular user can be achieved by flask_limiter. |
|
44aa4eb to
1fe99a2
Compare
1fe99a2 to
61a4a9d
Compare
262ab94 to
aa9782e
Compare
ba748fc to
5700b69
Compare
5700b69 to
e8030d8
Compare
e8030d8 to
16d9b2b
Compare
|
@iamareebjamal @niranjan94 I've updated the Please review |
|
|
||
| @auth_routes.route('/reset-password', methods=['POST']) | ||
| @limiter.limit( | ||
| '3/hour', key_func=lambda: request.json['data']['email'], error_message='Limit for this action exceeded' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jamal.areeb@gmail.com
jamalareeb@gmail.com
ja.mal.are.eb@gmail.com
Are all same email addresses and will be allowed by this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamareebjamal I just tested the above three email addresses.
Each one is distinguished perfectly and failed when the email if entered fourth time. I jumbled the order and tested, the reset request for one email is not affecting other in any way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I jumbled the order and tested, the reset request for one email is not affecting other in any way
It should
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that I can keep adding dots and sending emails at a rate of more than 3/hour
I can loop through a list of emails and send password reset request on them. Essentially brute forcing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But there is a check which raises error if user is not registered and so no mail is sent out. If a user loops by adding dots, it doesn't mean the email is registered and so error will be raised. I hope it makes sense to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A hacker doesn't care if the error is raised. He'll just continue looping through emails, and our resources will get exhausted. And users will still get spammed.
Also, raising error if user is not registered is a pretty big security issue, it should be fixed ASAP - #6069
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamareebjamal from what I understood, I should create a function which treats similar emails as same email. Right?
Also can you please guide me which pattern should I consider ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, you should add one more limiter which prevents same IP to access the unprotected resource at a lower rate, like '1/minute'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iamareebjamal I've updated the PR. Please review
16d9b2b to
64f0593
Compare
uds5501
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good!
* feat: Implement flask limiter on password-reset route * adds limiter to limit the request from same IP
Fixes #6033
Checklist
developmentbranch.Changes proposed in this pull request:
A threshold for an account reset email should be 3 times per hour. After that, the user receives a message: "You have reached the threshold for this action. Please try again in one hour."