You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With POST /user/{id} user can change password without of presence of old password. This is security problem, because anyone who stoles any valid access token from user can change users password.
Tasks
Only allow resetPassword by email if email verification is required and done.
Add a new method, let's call it User.changePassword(id, oldPassword, newPassword, cb). This method should have ACLs configured to allow only the owner to execute it (i.e. users can change only their own passwords) - see Add User.changePassword(id, old, new, cb) #3299
Scope the password-reset token so that it allows only changing User's password and nothing else. Regular access tokens must not allow changing User's password without providing the old one. Save the password-reset token the same way as the verification token i.e. with the user. That way you would know with which token you can change the password without knowing your old one. It would also mean that if you request another password reset it would delete/invalidate the previous token so that at max only one can be active at one time. Because the current implementation relies on the client to call updateAttributes with a temporary access token, I think we will need to implement a new method similar to User.changePassword that will accept the new reset-token instead of the old password.
The problem here is that on password reset you get normal short lived token, that you can't distinct from other tokens and at the same time you can't require old password on password reset, also having another view is a security issue. My proposal would be to tag tokens or is there any better idea?
Another idea would be to save it the same way as the verification token i.e. with the user. That way you would know with which token you can change the password without knowing your old one. It would also mean that if you request another password reset it would delete/invalidate the previous token so that at max only one can be active at one time.
@TFaga you want to be able to multiple tokens active at once. As a single user may be logged into a service from multiple locations (mobile, web, desktop app).
@offlinehacker you would want the token to stay valid, even if the password changes. As you if you change the password you would still want your moblie device to stay active.
Github manage this by being able to see what tokens are currently valid/active. Then the user can choose to remove the tokens to force that device to re-authenticate.
@karlmikko why wouldn't they, in loopback tokens are randomly generated and unrelated to password. Most general solution would be to have tokens with the scope where they can be used(verify,reset,auth).
@karlmikko Yes of course that functionality would remain unchanged. The problem is that when you request for a password reset it generates a normal (however short lived) token with which you can then do anything. However if the user model is changed so that you need to provide your current password when changing it you cannot reset your password with this method anymore (which is OK, you shouldn't be able to change your password without your current one). I currently see two ways to fix this issue (also using your password reset token, you should only be allowed to change your password and do nothing else - not the case now):
Don't save the password reset token as a normal one, instead save it the same way as the verification token, that way you would know what is it for. Also would mean that only one can be active at any time (not unreasonable), however you would need to save an expire date, which could prove to be a bit annoying.
Save all the tokens (normal, reset, verify) in the accessToken collection/table and add a type field to every token (possible values: reset, verify, auth as stated by @offlinehacker ), so that you know exactly what it's for and as such decide what the user can or cannot do with it (eg. token with type reset can only reset password, same for verify, ...). It would require a bit more change however I still think it's not that much actually and it would be a more general solution that nr. 1.
The access token model will be aligned with oAuth 2.0. It will have a scopes properties to represent the granted permissions. The access token will also have more identities, such as clientId (client application) and user id (resource owner). The oAuth 2.0 integration is under development. In the interim, we can start with an enhanced access token model.
All tasks listed in the issue in the issue description were landed and released in loopback@3.7.0. I am going to close this issue as resolved. See #3349 for the issue/task tracking update of documentation, examples and project templates. Help is welcome!
Activity
raymondfeng commentedon Jul 19, 2014
Good catch. We already have code to protect
emailVerifiedflag. It should apply topasswordtoo.See https://github.com/strongloop/loopback/blob/master/lib/models/user.js#L443.
Would you like to submit a patch?
offlinehacker commentedon Jul 19, 2014
The problem here is that on password reset you get normal short lived token, that you can't distinct from other tokens and at the same time you can't require old password on password reset, also having another view is a security issue. My proposal would be to tag tokens or is there any better idea?
TFaga commentedon Jul 19, 2014
Another idea would be to save it the same way as the verification token i.e. with the user. That way you would know with which token you can change the password without knowing your old one. It would also mean that if you request another password reset it would delete/invalidate the previous token so that at max only one can be active at one time.
karlmikko commentedon Jul 20, 2014
@TFaga you want to be able to multiple tokens active at once. As a single user may be logged into a service from multiple locations (mobile, web, desktop app).
karlmikko commentedon Jul 20, 2014
@offlinehacker you would want the token to stay valid, even if the password changes. As you if you change the password you would still want your moblie device to stay active.
Github manage this by being able to see what tokens are currently valid/active. Then the user can choose to remove the tokens to force that device to re-authenticate.
offlinehacker commentedon Jul 20, 2014
@karlmikko why wouldn't they, in loopback tokens are randomly generated and unrelated to password. Most general solution would be to have tokens with the scope where they can be used(verify,reset,auth).
offlinehacker commentedon Jul 20, 2014
@karlmikko And multiple tokens are already active at once
TFaga commentedon Jul 20, 2014
@karlmikko Yes of course that functionality would remain unchanged. The problem is that when you request for a password reset it generates a normal (however short lived) token with which you can then do anything. However if the user model is changed so that you need to provide your current password when changing it you cannot reset your password with this method anymore (which is OK, you shouldn't be able to change your password without your current one). I currently see two ways to fix this issue (also using your password reset token, you should only be allowed to change your password and do nothing else - not the case now):
Don't save the password reset token as a normal one, instead save it the same way as the verification token, that way you would know what is it for. Also would mean that only one can be active at any time (not unreasonable), however you would need to save an expire date, which could prove to be a bit annoying.
Save all the tokens (normal, reset, verify) in the accessToken collection/table and add a type field to every token (possible values: reset, verify, auth as stated by @offlinehacker ), so that you know exactly what it's for and as such decide what the user can or cannot do with it (eg. token with type reset can only reset password, same for verify, ...). It would require a bit more change however I still think it's not that much actually and it would be a more general solution that nr. 1.
Of course there might be somethings I missed.
raymondfeng commentedon Jul 20, 2014
Great discussions!
The access token model will be aligned with oAuth 2.0. It will have a
scopesproperties to represent the granted permissions. The access token will also have more identities, such as clientId (client application) and user id (resource owner). The oAuth 2.0 integration is under development. In the interim, we can start with an enhanced access token model.offlinehacker commentedon Aug 5, 2014
Why was this one closed?
On Aug 5, 2014 7:56 PM, "Al Tsang" notifications@github.com wrote:
altsang commentedon Aug 5, 2014
same thing here - I'm trying to clean up issues, I've labelled so I can track and closed them if there isn't further action/discussion at this moment
72 remaining items
bajtos commentedon Apr 27, 2017
All tasks listed in the issue in the issue description were landed and released in
loopback@3.7.0. I am going to close this issue as resolved. See #3349 for the issue/task tracking update of documentation, examples and project templates. Help is welcome!