diff --git a/providers/class-two-factor-email.php b/providers/class-two-factor-email.php index 9a644e32..8bb83ae3 100644 --- a/providers/class-two-factor-email.php +++ b/providers/class-two-factor-email.php @@ -317,7 +317,10 @@ public function validate_authentication( $user ) { return false; } - return $this->validate_token( $user->ID, $_REQUEST['two-factor-email-code'] ); + // Ensure there are no spaces or line breaks around the code. + $code = trim( sanitize_text_field( $_REQUEST['two-factor-email-code'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, handled by the core method already. + + return $this->validate_token( $user->ID, $code ); } /**