Fix it in your stack

Tested fixes for CWE-1275 in Express, Flask, Spring Boot, ASP.NET Core, Rails and Laravel: the vulnerable code, the fix, a plausible fix that still fails, and the regression tests.

Definition

MITRE’s description of CWE-1275: The SameSite attribute for sensitive cookies is not set, or an insecure value is used.

Common consequences MITRE lists

  • Confidentiality, Integrity, Non-Repudiation, Access Control: Modify Application Data

Why it matters

Cookies sent with cross-site requests make CSRF and some cross-site data leaks possible.

How to prevent it

  • Set SameSite=Lax or Strict explicitly on session cookies; use None only for flows that need it, and then with Secure.
  • Keep CSRF defenses such as Origin or Sec-Fetch-Site checks, because SameSite does not stop same-site attackers.

Guides on this site

Practice

References

  1. CWE-1275 in the MITRE CWE list (version 4.20)

List data from MITRE; the name, definition and consequences are from MITRE’s CWE 4.20 catalogue. A guide is listed as the main subject when the weakness is what the guide is about, and as covering it when a dedicated section or worked example addresses it.

CWE content: Copyright © 2006–2026, The MITRE Corporation. CWE, CWSS, CWRAF, and the CWE logo are trademarks of The MITRE Corporation. CWE™ is free to use by any organization or individual for any research, development, and/or commercial purposes, per these CWE Terms of Use. Accordingly, The MITRE Corporation hereby grants you a non-exclusive, royalty-free license to use CWE for research, development, and commercial purposes. Any copy you make for such purposes is authorized on the condition that you reproduce MITRE’s copyright designation and this license in any such copy. CWE is a trademark of The MITRE Corporation. CWE Terms of Use.