首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ASPXAUTH Cookie的安全旗帜

ASPXAUTH Cookie的安全旗帜
EN

Stack Overflow用户
提问于 2014-01-15 08:58:03
回答 4查看 19.5K关注 0票数 16

我们有一个面向外部的应用程序,由一家外部安全公司进行了渗透测试。应用程序已在ASP.NET MVC4上开发,并在IIS8 8/Windows2012Server上运行。

报告的一个漏洞是ASPXAUTH不安全。当我检查cookie检查员时,有一些带有安全标志的cookie。但ASPXAUTH不是其中之一。

我做了一些研究,并在web.config下面设置了这些标志

代码语言:javascript
复制
<forms loginUrl="~/Account/Login" timeout="2880"  requireSSL=""  name="AppName" />

代码语言:javascript
复制
<httpCookies httpOnlyCookies="true" requireSSL="true" />

尽管存在这些设置,但身份验证cookie并不被标记为安全。我认为这些标志应该足以将应用程序cookie标记为安全,但是还有一些其他的cookie也没有被标记为安全。我不太担心它们,因为它们不包含任何敏感信息。但我想把ASPXAUTH标记为安全。

我的问题是,

  1. 在web.config上设置这些标志后,没有安全标志的ASPXAUTH是否存在安全问题?
  2. 如果是的话,你能告诉我什么才是正确的方法来标记它的安全。

谢谢。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2014-01-17 16:10:48

我找到了使我的身份验证cookie安全的一段代码。我不记得它的来源,但是如果您将它添加到您的global.asax中,它会对问题进行排序。我不知道为什么,但是标签中的requireSSL=true并不足以保证它的安全性。

代码语言:javascript
复制
  protected void Application_EndRequest(Object sender, EventArgs e)
    {
        string authCookie = FormsAuthentication.FormsCookieName;

        foreach (string sCookie in Request.Cookies)
        {
            if (sCookie.Equals(authCookie))
            {
                // Set the cookie to be secure. Browsers will send the cookie
                // only to pages requested with https
                var httpCookie = Response.Cookies[sCookie];
                if (httpCookie != null) httpCookie.Secure = true;
            }
        }
    }
票数 17
EN

Stack Overflow用户

发布于 2016-01-05 17:53:34

您的问题似乎是因为您的表单配置不正确。你有:

代码语言:javascript
复制
<forms ... requireSSL="" ... />

你应该

代码语言:javascript
复制
<forms ... requireSSL="true" ... />

根据微软httpCookies标记中的requireSSL属性被forms标记的requireSSL属性覆盖。您没有设置值,但指定它可能会导致IIS使用默认的false。您应该将其设置为true

票数 12
EN

Stack Overflow用户

发布于 2014-01-15 09:04:05

回答你的第二个问题

可能重复的如何保护.ASPXAUTH令牌

根据赛尔科的答复

代码语言:javascript
复制
To prevent forms authentication cookies from being captured and tampered with while crossing the network, ensure that you use SSL with all pages that require authenticated access and restrict forms authentication tickets to SSL channels by setting requireSSL="true" on the <forms> element.

To restrict forms authentication cookies to SSL channels set requireSSL="true" on the <forms> element, as shown in the following code:

<forms loginUrl="Secure\Login.aspx" requireSSL="true" ... />

By setting requireSSL="true", you set the secure cookie property that determines whether browsers should send the cookie back to the server. With the secure property set, the cookie is sent by the browser only to a secure page that is requested using an HTTPS URL.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21132912

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档