Cookie Not getting expired after logout from Identityserver4 : .net core 2.0
I am using identityserver4 for all configured clients with "AccesssTokenType=1" i.e. reference type.
I have one web app hosted for server, and other one for clients.
I used default identityserver settings, which generated two cookie, one for session Id "idsrv.session", and other one for authentication "idsrv".
In logout I do signout
await HttpContext.SignOutAsync(IdentityServerConstants.ExternalCookieAuthenticationScheme);
await HttpContext.SignOutAsync(IdentityServerConstants.DefaultCookieAuthenticationScheme);
however it gives error when I call with "idsrv.session" await HttpContext.SignOutAsync(IdentityServerConstants.DefaultCheckSessionCookieName);
Issue / Steps to reproduce the problem
1st Iteration : Login on my client website which redirects to my identityserver application. I now interceprt the request and response using "Burp Suite". I copy the complete response which has redirect URL's and cookie details.
I signout/logout from client website.
2nd Iteration : I tried login again, and intercepted the request and response using Burp Suite, by passing wrong credential. While Intercepting the response I just copied the cookies from previous request (which was successful in my first iteration), and observe that identityserver has successfully validated the user using the cookie value, ignoring the wrong credentials in this iteration.
Even I tried invalidating and deleting cookies in my signout/logout method, but looks like identityserver still recognises it as the valid ones.
Scheme idsrv.session is not a cookie authentication handler scheme identifier. It's just an internal cookie we maintain and when you get rid of the DefaultCookieAuthenticationScheme we will cleanup up the other cookie.
Hi @brockallen, I understood that part. I am also doing await HttpContext.SignOutAsync(); along with "idsrv" & "idsrv.external".
Please let me know if I am able to explain my scenario better or should I add more description/code.
Can anyone help me fixing this security venerability.
I understood that part.
Then you should know there's no point in using HttpContext.SignOut to clear it.
Can anyone help me fixing this security venerability.
What security venerability?
Thank you @brockallen for your response.
We have done VAPT testing of our product and below are the observation
Step 1: End User logins to the client website by entering the proper credentials. Step 2: In between I've intercepted the request using the "Burp Suite" tool and copied the complete response. This response comprises of all the redirect URLs and the cookie value. Step 3: I signed out from the client application. Step 4: Signed in to the client website by entering the wrong credentials. Step 5: Intercepted the request. Step 6: While intercepting the response used the cookie value which has been intercepted in Step 2. Step 7: Identity server successfully authenticates the user.
The main security vulnerability is that even when a user enters a wrong credentials the system is allowing the user to login.
Step 2: In between I've intercepted the request using the "Burp Suite" tool and copied the complete response. This response comprises of all the redirect URLs and the cookie value.
Sure, and this type of attack could steal the user's original password too.
Step 3: I signed out from the client application.
This is the real issue you're asking about -- when you signout, you want the cookie to no longer be valid, even in the scenario when it's stolen and replayed. This is not something IdentityServer can address, because we use Microsoft's cookie authentication to achieve signin. You would have to fix this by changing the default usage of their component. You can do it by implementing "server-side cookie" (a term that I dislike) by implementing an ITicketStore: https://github.com/aspnet/Security/blob/master/src/Microsoft.AspNetCore.Authentication.Cookies/CookieAuthenticationOptions.cs#L136
Thank you @brockallen for the correct direction. This approach wored and have fixed my problem.
So, the basic problem is with Microsoft .net Core cookie Managemnt, its not handling the lifetime of cookies correctly.
Identityserver is awesone 👍 🥇
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.