Not Secure Cookie

  • CWE 614

Not Secure Cookie occurs when cookies are transmitted over unencrypted HTTP connections without the Secure attribute. This allows attackers to intercept or manipulate cookies through network-based attacks such as man-in-the-middle (MITM). Sensitive information in cookies, including session identifiers, authentication tokens, or personal data, can be exposed or hijacked, leading to unauthorized access or account compromise.

Common patterns leading to insecure cookies:

  • Setting session or authentication cookies without the Secure flag.
  • Transmitting cookies over HTTP instead of HTTPS.
  • Misconfigured web server or framework defaults that do not enforce secure cookie transmission.
  • Mixed-content pages that allow HTTP connections alongside HTTPS, enabling cookie exposure.

Impacts:

  • Session Hijacking: Attackers can capture cookies over unencrypted channels to impersonate users.
  • Sensitive Data Exposure: Any confidential data stored in cookies can be intercepted.
  • Account Compromise: Stolen cookies can be used to gain unauthorized access to accounts.
  • Privilege Escalation: Attackers can use intercepted cookies to escalate privileges or bypass authentication.

Detection indicators:

  • Cookies returned in HTTP responses without the Secure flag.
  • Cookies transmitted over plain HTTP connections.
  • Security scanners flagging cookies as not secure.
Remediation

Mitigation focuses on securing cookie transmission and enforcing encryption:

  1. Set Secure Attribute on Cookies
    Mark all session, authentication, and sensitive cookies with the Secure flag to ensure they are only transmitted over HTTPS.

  2. Enforce HTTPS Across the Application
    Redirect all HTTP traffic to HTTPS and disable non-secure connections.

  3. Combine Secure with HttpOnly
    Use Secure alongside HttpOnly to prevent both network interception and client-side access via scripts.

  4. Limit Cookie Scope
    Use the Path and Domain attributes to restrict cookie accessibility to intended endpoints.

  5. Review Framework and Server Defaults
    Ensure web server and application framework configurations enforce secure cookie transmission by default.

  6. Regular Security Testing
    Include checks for missing Secure flags in cookies during penetration tests and automated scans.

  7. Monitor and Audit Cookies
    Track HTTP responses and cookie attributes to confirm that sensitive cookies are properly flagged.

References