Skip to content

Sensitive Cookie in HTTPS Session Without 'Secure' Attribute

Description

Storing sensitive data in a persistent cookie for an extended period can lead to a breach of confidentiality or account compromise.

Examples

Insecure Code

scala
val cookie = new Cookie("session", "value"); cookie.setMaxAge(31536000)

Secure Code

scala
val cookie = new Cookie("session", "value"); cookie.setSecure(true); cookie.setMaxAge(3600)

Remediation

Set the 'Secure' attribute for the cookie and consider using a shorter max age.

Rule Details

FieldValue
IDCODE-0009
CategoryWeb
SeverityMEDIUM
CWECWE-614
ConfidenceHIGH
ImpactMEDIUM
LikelihoodMEDIUM
ExploitabilityEASY
Tagscookie, https, security
OWASPN/A