Skip to content
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

serializers fails to sanitize the email in the ResetPasswordRequestToken view #144

Open
JoueBien opened this issue Aug 13, 2021 · 2 comments
Assignees

Comments

@JoueBien
Copy link

The route

`/rest-auth/password_reset/` 

is able to accept malformed emails. The sanitization doesn't strip leading or trailing spaces. This along with

DJANGO_REST_PASSWORDRESET_NO_INFORMATION_LEAKAGE = True

means that users can end up getting stuck with not getting a re-set email even if they entered in a seemingly valid email.

The change I would suggest is with ResetPasswordRequestToken@POST:

# this 
email = serializer.validated_data['email']
# should probably be this
email = serializer.validated_data['email'].strip()

There probably should be a regression test added to your test suite as well.

@nezhar
Copy link
Member

nezhar commented Aug 18, 2021

Thanks for the detailed description 👍, this is indeed something that can cause problems.

We intend to go ahead and use a custom lookup (#93) field in future, so we don't necessary stick to email.

What I would suggest instead is to add an additional configuration:

DJANGO_REST_PASSWORDRESET_STRIP_LOOKUP_FIELD_INPUT = True

By defaulting it to False we should avoid any regressions. What do you think?

@JoueBien
Copy link
Author

Yeah, I think that will work well along with keeping things with the existing default so we don't unexpectedly change the behaviour when people start a new project or run a deployment.

@nezhar nezhar assigned nezhar and unassigned JoueBien Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants