Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security]: Avoid user enumeration via reset password link #808

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/Controller/Admin/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,18 +274,13 @@ public function lostpasswordAction(

if ($error) {
Logger::error('Lost password service: ' . $error);
//to avoid timing based enumeration
usleep(random_int(50,200));
}
}

$csrfProtection->regenerateCsrfToken($request->getSession());

if ($error) {
$params['reset_error'] = 'Please make sure you are entering a correct input.';
if ($error === 'user_reset_password_too_many_attempts') {
$params['reset_error'] = 'Too many attempts. Please retry later.';
}
}

return $this->render('@PimcoreAdmin/admin/login/lost_password.html.twig', $params);
}

Expand Down
19 changes: 5 additions & 14 deletions templates/admin/login/lost_password.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,11 @@
{% block content %}

{% if app.request.method == 'POST' %}
{% if reset_error is not defined %}
<div class="text success">
{{ 'A temporary login link has been sent to your email address.'|trans([],'admin') }}
<br/>
{{ 'Please check your mailbox.'|trans([],'admin') }}
</div>
{% else %}
<div class="text error">
{{ 'An error occured when resetting password:'|trans([],'admin') }}
{{ reset_error|trans([],'admin') }}
<br/>
{{ 'Please retry again later or contact an administrator.'|trans([],'admin') }}
</div>
{% endif %}
<div class="text success">
{{ 'A temporary login link has been sent to your email address.'|trans([],'admin') }}
<br/>
{{ 'Please check your mailbox.'|trans([],'admin') }}
</div>
{% else %}
<div class="text info">
{{ 'Enter your username and pimcore will send a login link to your email address'|trans([],'admin') }}
Expand Down
Loading