GHSA-X239-6JQX-5HJH
Password reset and activation tokens compared with non-constant-time === instead of hash_equals(), and reset-submission endpoint has no rate limiting
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-X239-6JQX-5HJH divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
classes/Controller.php's taskReset() and login.php's account activation handler both
compare the stored secret token against the user-supplied token using a plain ===
string comparison, a non-constant-time, early-exit comparison. This is CWE-208. The
same plugin correctly uses hash_equals() for two adjacent, analogous checks (the
RememberMe token storage and the magic-link login flow), so this looks like an
oversight on the two highest-stakes comparisons in the plugin rather than an
intentional choice.
The core evidence
Password reset, classes/Controller.php, taskReset():
[$good_token, $expire] = explode('::', $user->reset);
if ($good_token === $token) {
...
$user->password = $password;
$user->save();
Account activation, login.php:
[$good_token, $expire] = explode('::', $user->activation_token);
if ($good_token === $token) {
Compare with the correct pattern already used elsewhere in this same plugin:
classes/RememberMe/TokenStorage.php:
if (!hash_equals($stored, $token)) { ... }
login.php magic link flow:
if (!hash_equals($storedHash, $tokenHash)) { ... }
Live demonstration of the underlying timing effect
I measured PHP's === versus hash_equals() directly, 200,000 iterations per case,
median filtered, on a 32-character token matching the md5(uniqid($random_bytes, true))
format used here.
=== (used in reset/activation):
wrong from position 0: 69 ns
correct first 31 chars: 72 ns
spread: 4.3%
hash_equals (used elsewhere in this plugin):
wrong from position 0: 128 ns
correct first 31 chars: 128 ns
spread: 0.0%
This confirms the real, language level effect exists and behaves exactly as expected.
hash_equals shows zero variance regardless of match position. I want to be precise
about scope. At roughly 3ns per character locally, this is a weak signal to extract
over real network jitter, which is normally microsecond to millisecond scale. This is
not a one request exploit.
What changes the practical risk: no rate limiting on the actual guessing endpoint
I checked whether taskReset(), the endpoint that receives and compares $token, is rate
limited. It is not. The only rate limiter I found in this flow (the pw_resets context)
fires earlier, on the step that requests a reset email be sent, not on token
submission. Nothing stops an attacker from submitting unlimited attempts against a
known username to statistically average out network noise, which is exactly what a
practical remote timing attack needs in order to overcome a weak per request signal.
Honest scoping
I have not built, and do not have a way to ethically build, a genuine network based
demonstration proving this is exploitable end to end against real infrastructure. That
would require a live target and heavy statistical sampling. I am reporting the
confirmed facts: the wrong comparison function is used, the underlying timing effect is
real and measured, there is no rate limit on the endpoint that would otherwise blunt a
repeated sampling attack, and the fix has zero downside. I would rather hand over an
honestly scoped moderate finding than an overclaimed critical one I cannot back with a
live network PoC.
Impact
An attacker who can extract enough signal from the timing difference, aided by the
complete absence of rate limiting on the token submission endpoint, could recover a
valid password reset token for a known username and set an arbitrary new password on
that account, or recover a valid activation token and activate (and in some
configurations, per plugins.login.user_registration.options.login_after_registration,
log in as) an account they do not control.
Suggested fix
Replace both === comparisons with hash_equals(), matching the pattern already used
correctly elsewhere in this plugin. Also add rate limiting to taskReset()'s token
check itself, not only to the earlier email request step.
Affected component
- classes/Controller.php, taskReset()
- login.php, account activation token check
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistgetgrav/grav-plugin-login |
Sin parche | — | — | — |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/getgrav/grav/security/advisories/GHSA-x239-6jqx-5hjhLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
