-
Notifications
You must be signed in to change notification settings - Fork 302
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
Ensure device has not been logged out #461
Ensure device has not been logged out #461
Conversation
0abee2e
to
1f97c6b
Compare
This adds a middleware to check that the password has in session is the same as the current users password. This fixes a security issue where an attacker can keep sending requests to an API using the sanctum auth after the password has been changed.
1f97c6b
to
9392ec9
Compare
Can you not just use the already existing https://laravel.com/docs/10.x/authentication#invalidating-sessions-on-other-devices |
From what I can see, adding
There is also a fatal call to logoutCurrentDevice
As it's quite difficult to test for this I have set up a test repo that has both the Related issues |
@patrickomeara using this middleware - how does the password hash get stored in the session in the first place? Is it stored by Furthermore, what are the breaking change implications if we tag this on a patch release and people are not already using |
* this means the original request had `auth.session` middleware
91e363d
to
fc7c77e
Compare
Yes the original web request stores the password hash in the session. This is the existing mechanism that logs out other sessions on password change. This newly added Sanctum-only middleware will log out the sanctum sessions as well. I've added a check so if the original request isn't using |
I've updated the test repo to use this branch of sanctum. |
I'm converting this to draft as I've found a condition where the guard changes from web to sanctum when changing the password via a sanctum request and logs the current session out. |
Closing, as laravel/framework#48056 is a better approach to this problem. |
This adds a middleware to check that the password hash in session is the same as the current users password, and logs the user out if not.
This fixes a security issue where an attacker can keep sending requests to an API using the sanctum auth after the password has been updated.
Scenario:
If a user is logged in in two different browsers, they change their password in one, the web session is invalidated in the other, but requests can still be sent via the sanctum cookie auth to the API.
refs #142