Insecure Cookie Configuration

Detects cookies set without Secure, HttpOnly, or SameSite attributes.

zakirkun 7bffa4d 2 files · 4.2 KB Updated

File contents

Insecure Cookie Configuration

Overview

Cookies that store session tokens or authentication data must be configured with security attributes to prevent theft and CSRF attacks:

  • Secure: Cookie only sent over HTTPS
  • HttpOnly: Cookie inaccessible to JavaScript (prevents XSS token theft)
  • SameSite: Prevents cross-site request forgery (Strict or Lax)

Missing any of these attributes expands the attack surface.

Detection Strategy

Look for Set-Cookie headers or cookie-setting function calls that omit one or more of the critical security flags.

Remediation

Always set session cookies with all three security attributes.

Vulnerable (Go):

http.SetCookie(w, &http.Cookie{
    Name:  "session",
    Value: token,
})

Safe (Go):

http.SetCookie(w, &http.Cookie{
    Name:     "session",
    Value:    token,
    Secure:   true,
    HttpOnly: true,
    SameSite: http.SameSiteStrictMode,
})

zakirkun/ice-tea/tree/main/skills/auth/insecure-cookie commit 7bffa4dedd

Frequently asked questions

npx skillmds@latest add zakirkun/insecure-cookie-configuration