Use email verification when changing user email addresses

Created on 22 September 2006, almost 19 years ago
Updated 1 February 2023, over 2 years ago

Problem/Motivation

Currently, when a new user registers for a Drupal account the details are sent to the user's supplied email address. This provides a basic mechanism that confirms the user is at that email address. However, once registered, users are permitted to change their email address without further confirming that the user is in fact at that email address.

Possible implications

  • A user can change email address to be that of an unsuspecting third party as no confirmation of change is required. Using a second Drupal account (with it's email address also faked using the same method) the first user is then able to send anonymous malicious messages to the unsuspecting third party
  • A slow method for sending spam but exploitable none the less

Proposed resolution

Add a mechanism (similar to reset password) that:

  1. Sends an E-mail to the new address requiring the verification of the new address (similar to register confirmation).
  2. Sends a notification E-mail to the old address.
  3. Allow the site builder to customise both messages at admin/config/people/accounts
  4. Provides an update path to set the default behaviour and messages content.
  5. Write tests.

This new mechanism is bypassed if the e-mail address is changed by an administrator.

Remaining tasks

  1. #279.2:
  2. - Not easy to test as involves email send failure - code seems OK
  3. - Addressed around #356, with new test included
  4. Security review.
  5. Follow-up questions from #270: (Potentially follow up change as there are other potential improvements in #358 that would resolve a lot of these and go further to improve UX)
    1. Should there be some indication that additional form fields are available once checked? (NOTE: Same issue in Account Canceled email form)
    2. Should the suggestions exist prior to checking the box? (NOTE: Same issue in Account Canceled email form)
    3. Should we make the request visible as pending to user and/or admin until completion?
    4. Should there be visible history (related question, are users revisionable)?
  6. Follow-up questions from #272:
    1. - In #312 noted admin users are generally able to do a lot of things without checks, including remove their own rights, so already trustworthy to set a new email correctly without needing to verify it

User interface changes

New UI additions to admin/config/people/accounts:

New confirmation message (warning) when user changes e-mail address:

Default text of the generated e-mail (some elements will vary):

alice,

A request to change your email address has been made at Drupal Usability. You
need to verify the change by clicking on the link below or copying and
pasting it in your browser:

http://drupalux.lndo.site/user/mail-change/2/alice%40example.org/1542687...

This is a one-time URL, so it can be used only once. It expires after one
day. If not used, your email address at Drupal Usability will not change.

After using the one-time link, the user is redirected to the site's home page, with the message (info)

Your email address has been changed to alice@example.org.

API changes

New controller used for mail changing: \Drupal\user\Controller\MailChangeController

Data model changes

New schema for configs user.settings and user.mail.

Release notes snippet

When users wish to change their email, they must now verify the email belongs to them using a link sent to that address. This behavior is enabled by default on new installations but disabled by default on existing installations. Review the change record โ†’ for more information.

๐Ÿ› Bug report
Status

Needs work

Version

10.1 โœจ

Component
User moduleย  โ†’

Last updated 17 days ago

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom AjK

Live updates comments and jobs are added and updated live.
  • Security

    It is used for security vulnerabilities which do not need a security advisory. For example, security issues in projects which do not have security advisory coverage, or forward-porting a change already disclosed in a security advisory. See Drupalโ€™s security advisory policy for details. Be careful publicly disclosing security vulnerabilities! Use the โ€œReport a security vulnerabilityโ€ link in the project pageโ€™s sidebar. See how to report a security issue for details.

  • Security improvements

    It makes Drupal less vulnerable to abuse or misuse. Note, this is the preferred tag, though the Security tag has a large body of issues tagged to it. Do NOT publicly disclose security vulnerabilities; contact the security team instead. Anyone (whether security team or not) can apply this tag to security improvements that do not directly present a vulnerability e.g. hardening an API to add filtering to reduce a common mistake in contributed modules.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024