two_factor_authentication icon indicating copy to clipboard operation
two_factor_authentication copied to clipboard

Two factor authentication ignores devise registration edit and update

Open mesbahmilad opened this issue 10 years ago • 6 comments

If the two-factor authentication is turned on, the user can still navigate to the edit registration path and update the information.

mesbahmilad avatar Jan 29 '15 00:01 mesbahmilad

Thanks for your report, could you please provide some example?

Houdini avatar Jan 30 '15 00:01 Houdini

Example:

If the devise model is "user", once logged in you are presented with the two-factor authentication wall to enter the code. From here you can navigate to "users/edit" and since this is a devise controller the gem skips code validation.

Once in the edit view you can edit the user information without being authorized with the code.

Ps. Great gem!

mesbahmilad avatar Feb 02 '15 19:02 mesbahmilad

@mesbahmilad This can be solved by overriding the Devise RegistrationsController in your app (or any other controller where you want to enforce 2FA), and adding a before_action, such as:

before_action :confirm_two_factor_authenticated, except: [:new, :create, :cancel]

def confirm_two_factor_authenticated
  return if is_fully_authenticated?

  flash[:error] = t('devise.errors.messages.user_not_authenticated')
  redirect_to user_two_factor_authentication_url
end

monfresh avatar Dec 23 '15 03:12 monfresh

This is a pretty huge security flaw. You can sign in without 2FA, go to the edit page and disable 2FA from there. I'd recommend adding a note in the README at least.

wrgoto avatar Jun 19 '18 17:06 wrgoto

This note should definitely be added to the readme, as a post-setup installation note. Can the gem be secured internally, though?

Tectract avatar Nov 30 '18 17:11 Tectract

I made a PR, here:

https://github.com/Houdini/two_factor_authentication/pull/160

I'm not sure why it failed travis-CI, I only updated the readme...

Tectract avatar Nov 30 '18 19:11 Tectract