小编Jul*_*e20的帖子

保护 Owin Cookie http 和 https

在我们的网站上进行了渗透测试,我们被告知该网站没有安全的 cookie。这是在 Http 和 Https 上的。

我已经尝试了很多例子,但 cookie 仍然没有勾选安全。我不知道我哪里出错了。

这是我在网络配置中尝试过的:

Solution 1 
<httpCookies requireSSL="true"/>

Solution 2
<httpCookies httpOnlyCookies="true" requireSSL="true" />

Solution 3
<httpCookies requireSSL="true" lockItem="true"   />

Solution 4
    <authentication mode="Forms">
    <forms loginUrl="Layout_Simple.cshtml" cookieless="UseCookies"  requireSSL="true"   path="/Account/Login" />
    </authentication>
Run Code Online (Sandbox Code Playgroud)

在尝试了这些解决方案中的每一个之后,cookies 仍然不安全 在此处输入图片说明

然后我尝试了 Global.asax.cs 文件中的代码。像这样运行网站时,cookies 仍然不安全

 protected void Application_EndRequest(object sender, EventArgs e)
    {
       if (Response.Cookies.Count > 0)
       {
          foreach (string s in Response.Cookies.AllKeys)
         {
           if (s == FormsAuthentication.FormsCookieName || s.ToLower() == "_requestverificationtoken" || s.ToLower() == ".aspnet.applicationcookie") || s.ToLower() == "asp.net_sessionid"
           {
              Response.Cookies[s].Secure = …
Run Code Online (Sandbox Code Playgroud)

c# cookies asp.net-mvc owin

5
推荐指数
1
解决办法
1167
查看次数

标签 统计

asp.net-mvc ×1

c# ×1

cookies ×1

owin ×1