我们有一个面向外部的应用程序,由一家外部安全公司进行了渗透测试。应用程序已在ASP.NET MVC4上开发,并在IIS8 8/Windows2012Server上运行。
报告的一个漏洞是ASPXAUTH不安全。当我检查cookie检查员时,有一些带有安全标志的cookie。但ASPXAUTH不是其中之一。
我做了一些研究,并在web.config下面设置了这些标志
<forms loginUrl="~/Account/Login" timeout="2880" requireSSL="" name="AppName" />和
<httpCookies httpOnlyCookies="true" requireSSL="true" />尽管存在这些设置,但身份验证cookie并不被标记为安全。我认为这些标志应该足以将应用程序cookie标记为安全,但是还有一些其他的cookie也没有被标记为安全。我不太担心它们,因为它们不包含任何敏感信息。但我想把ASPXAUTH标记为安全。
我的问题是,
谢谢。
发布于 2014-01-17 16:10:48
我找到了使我的身份验证cookie安全的一段代码。我不记得它的来源,但是如果您将它添加到您的global.asax中,它会对问题进行排序。我不知道为什么,但是标签中的requireSSL=true并不足以保证它的安全性。
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;
}
}
}发布于 2016-01-05 17:53:34
您的问题似乎是因为您的表单配置不正确。你有:
<forms ... requireSSL="" ... />你应该
<forms ... requireSSL="true" ... />根据微软,httpCookies标记中的requireSSL属性被forms标记的requireSSL属性覆盖。您没有设置值,但指定它可能会导致IIS使用默认的false。您应该将其设置为true。
发布于 2014-01-15 09:04:05
回答你的第二个问题
可能重复的如何保护.ASPXAUTH令牌
根据赛尔科的答复
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.https://stackoverflow.com/questions/21132912
复制相似问题