Skip to content

Sensitive cookie in HTTPS session without 'Secure' attribute

Description

The `Secure` attribute when set to `true` protects the cookie value from being transmitted over clear text communication paths such as HTTP. By enabling this protection, the cookie will only be sent over HTTPS. Session cookies should be configured with the following security directives: HTTPOnly, SameSite, and Secure.

Examples

Insecure Code

c#
var cookie = new HttpCookie("SomeCookieName", "SomeValue");

Secure Code

c#
var someCookie = new HttpCookie("SomeCookieName", "SomeValue");
someCookie.Secure = true;

Remediation

Set the `Secure` attribute to `true` for the HttpCookie object, e.g., `someCookie.Secure = true;`

Rule Details

FieldValue
IDCODE-0440
CategorySecrets
SeverityLOW
CWECWE-614
ConfidenceHIGH
ImpactLOW
LikelihoodMEDIUM
ExploitabilityEASY
Tagscookie, secure, https
OWASPA6:2017-Security Misconfiguration, A05:2021-Security Misconfiguration