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

Password reset does not work due to CSRFError #4463

Closed
redshiftzero opened this issue May 24, 2019 · 0 comments · Fixed by #4498
Closed

Password reset does not work due to CSRFError #4463

redshiftzero opened this issue May 24, 2019 · 0 comments · Fixed by #4498
Labels

Comments

@redshiftzero
Copy link
Contributor

redshiftzero commented May 24, 2019

Description

Bug discovered by @lev-csouffrant.

Steps to Reproduce

  1. Login to journalist interface
  2. Try to reset password

Expected Behavior

  1. Password is reset

Actual Behavior

  1. You are logged out

Comments

This was introduced in #4425 (only in develop, not in production or any release branches) and is due to a missing CSRF token in the password reset form (a CSRFError exception will be thrown - these are handled in journalist_app/__init__py so no traceback occurs, but the form still won't validate):

diff --git a/securedrop/journalist_templates/edit_account.html b/securedrop/journalist_templates/edit_account.html
index fc54f2ebc..11f55cef3 100644
--- a/securedrop/journalist_templates/edit_account.html
+++ b/securedrop/journalist_templates/edit_account.html
@@ -58,6 +58,7 @@

 <form action="{{ password_reset_url }}" method="post" id="new-password" class="login-form">
    {% if not user or g.user == user %}
+  <input name="csrf_token" type="hidden" value="{{ csrf_token() }}">
   <p><input type="password" name="current_password" placeholder="{{ gettext('Current Password') }}"></p>
   <p><input name="token" id="token" type="text" placeholder="{{ gettext('Two-factor Code') }}"></p>
   {% endif %}

A fix needs a regression unit or functional test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant