Skip to content

chore: disallow password resets to unverified email #18088

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

miketheman
Copy link
Member

Only allow account resets to verified email addresses to prevent account
domain resurrection attacks.

If the user account exists for a given email address, check if the
account is verified. If it's not, reject with a flash message.

Does not disclose the name of a given user account, logs an event/warning for inspection.

miketheman added 3 commits May 5, 2025 12:14
Only allow account resets to verified email addresses to prevent account
domain resurrection attacks.

Signed-off-by: Mike Fiedler <[email protected]>
If the user account exists for a given email address, check if the
account is verified. If it's not, reject with a flash message.

Signed-off-by: Mike Fiedler <[email protected]>
Signed-off-by: Mike Fiedler <[email protected]>
@miketheman miketheman added security Security-related issues and pull requests email Related to emails labels May 5, 2025
@miketheman miketheman requested a review from a team as a code owner May 5, 2025 17:56
@miketheman
Copy link
Member Author

Screenshot 2025-05-05 at 13 51 57

Comment on lines +811 to +814
if unverified_email := first_true(
user.emails,
pred=lambda e: e.email == form.username_or_email.data,
):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conditional doesn't work when attempting to request password reset by username: verified_email becomes None, but this query is searching for an email that matches the username, not the email address, so it will never succeed.

I'm surprised the tests & coverage are OK with this? Something is falling between the cracks here.

Comment on lines +824 to +831
request.session.flash(
request._(
"Email address '${email}' is not verified. "
"Contact PyPI support for assistance.",
mapping={"email": unverified_email.email},
),
queue="error",
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also slightly concerned that this will become an oracle. I think instead, if we get a password reset for an unverified email, we should just send that address an email "Password reset requested but this email address is currently unverified" and just display the same ambiguous message here instead.

Copy link
Member Author

@miketheman miketheman May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand the threat vector this kind of oracle would provide?
It'll confirm the existence of an email address that isn't able to be used without an account recovery via support. It does not expose who the email address is associated with.

I'm generally okay to consider another email template to send to unverified email addresses, but that has the downside of us trying to email places that have already had either a hard bounce, expiration, or some other reason that the address is unverified, and could affect our sender scores.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
email Related to emails security Security-related issues and pull requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants