在ASP.NET MVC 5的UseCookieAuthentication()中使用无cookie或会话cookie

问题描述 投票:0回答:1

我有一个使用Cookie身份验证的ASP.NET MVC 5应用程序。但是,在进行渗透测试后,它很容易受到MITM攻击,如果该cookie被盗,可以重新使用该cookie。

// Enable the application to use a cookie to store information for the signed in user
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Authentication/Login")
});
  1. 我的问题是:如何使注销后的cookie失效/失效? (不是cookie本身,而是ASP.NET使用的cookie值)

  2. 此cookie似乎不受web.configsessionState的控制,可以将其存储在内存中。是否可以将上述cookie配置为存储为会话cookie?

<sessionState mode="InProc" ... />
  1. 还有更好的方法吗?
asp.net-mvc owin
1个回答
0
投票

您可以实现自己的ITicketStore来保持会话中的价值。您的实现进入CookieOptions的SessionStore。虽然我不会使用InProc。这使您可以在注销时将其杀死。另一件事是您应该设置ExpireTimeSpan。从技术上讲,MITM攻击仍将起作用,但这会使它变得更难。

© www.soinside.com 2019 - 2024. All rights reserved.