Problem/Motivation

Claude Opus 4.8 analysis:

  ChangeEmailNoPassword.php:106-107
  $account->setEmail($email_address);
  if (boolval($account->save())) {
  save() does not run entity constraint validation. In Drupal, both email format (Email constraint) and email uniqueness
  (UserMailUnique) are enforced only when $account->validate() is explicitly called (as forms and JSON:API do). Saving
  directly skips both.

  Consequences:
  - Duplicate email / impersonation vector: a user can set their email to an address already used by another account
  (including an admin's). Drupal has no DB-level unique constraint on mail, so the collision persists silently. This
  corrupts the assumption that email→account is unique and can interfere with the victim's password-reset flow
  (user_load_by_mail / reset keyed on email becomes ambiguous).
  - Malformed data: any string passes — "not-an-email", an empty string, strings with whitespace/newlines. An empty email
  can break the account's own password-recovery path.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ptmkenny created an issue. See original summary.

ptmkenny’s picture

Title: Security: Email is saved without user validation » Security: Validate email when saving

  • ptmkenny committed 205f21f3 on 3.0.x
    fix: #3605285 Security: Validate email when saving
    
    By: ptmkenny
    
ptmkenny’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.