Skip to content

Insecure Cookie Creation

Description

A new cookie is created without the Secure flag set, allowing it to be sent over insecure communication channels.

Examples

Insecure Code

scala
val C = new javax.servlet.http.Cookie("name", "value");
response.addCookie(C);

Secure Code

scala
val C = new javax.servlet.http.Cookie("name", "value");
C.setSecure(true);
response.addCookie(C);

Remediation

Set the Secure flag to true when creating a new cookie using the setSecure(true) method.

Rule Details

FieldValue
IDCODE-0008
CategoryWeb
SeverityLOW
CWECWE-539
ConfidenceHIGH
ImpactLOW
LikelihoodMEDIUM
ExploitabilityEASY
Tagscookie, secure flag
OWASPN/A