Skip to content

Sensitive cookie without 'HttpOnly' and 'Secure' flags

Description

The detected issue pertains to a Rails application where the session configuration, specifically using cookie_store, has been identified with the $KEY attribute set to false. This setting is potentially insecure because it may relate to crucial security attributes such as HttpOnly or Secure flags not being enforced. In the context of web applications, these flags play a vital role in enhancing session security.

Examples

Insecure Code

ruby
Rails.application.config.session_store :cookie_store, key: '_your_app_session', httponly: false, secure: false

Secure Code

ruby
Rails.application.config.session_store :cookie_store, key: '_your_app_session', httponly: true, secure: Rails.env.production?

Remediation

Set the 'HttpOnly' and 'Secure' flags to true in the session configuration. For example: `Rails.application.config.session_store :cookie_store, key: '_your_app_session', httponly: true, secure: Rails.env.production?`

Rule Details

FieldValue
IDCODE-0518
CategoryWeb
SeverityLOW
CWECWE-1004
ConfidenceHIGH
ImpactLOW
LikelihoodMEDIUM
ExploitabilityEASY
Tagssession management, cookie security
OWASPA6:2017-Security Misconfiguration, A05:2021-Security Misconfiguration

References