The program creates a cookie, but fails to set the HttpOnly
flag to true
.
Microsoft Internet Explorer supports the HttpOnly
cookie property that prevents client-side scripts from accessing the cookie. Cross-Site Scripting attacks often access cookies in an attempt to steal session identifiers or authentication tokens. When HttpOnly
is not enabled, attackers can more easily access user cookies.
Example 1: The code in the example below creates a cookie without setting the HttpOnly
property.
HttpCookie cookie = new HttpCookie("emailCookie", email);
Response.AppendCookie(cookie);
[1] Standards Mapping - OWASP Top 10 2004 - (OWASP 2004) A10 Insecure Configuration Management
[2] Standards Mapping - OWASP Top 10 2010 - (OWASP 2010) A6 Security Misconfiguration
[3] Standards Mapping - FIPS200 - (FISMA) CM
[4] HttpCookie.HttpOnly Property Microsoft
[5] Standards Mapping - Web Application Security Consortium 24 + 2 - (WASC 24 + 2) Insufficient Authentication
[6] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 - (PCI 1.1) Requirement 6.5.10
[7] Amit Klein Round-up: Ways to bypass HttpOnly (and HTTP Basic auth)