Skip to content

Update: Cross-Site Request Forgery Prevention Cheat Sheet - add Fetch Metadata #1803

@mkhanas

Description

@mkhanas

What is missing or needs to be updated?

The CSRF Cheat Sheet currently lacks any mention of Fetch Metadata (Sec-Fetch-*) headers. Sec-Fetch-Site (and related Sec-Fetch-* headers) let servers determine the context of a request (e.g. same-originsame-sitenonecross-site) and therefore provide a reliable way to block obvious cross-site requests before they reach application logic.

While modern browsers provide these headers and many sources recommend using them as a CSRF mitigation:

  1. Other OWASP cheat sheets (for example, Cookie Theft Mitigation and XS-Leaks) already mention Sec-Fetch-*. The CSRF Cheat Sheet should likewise document this technique as a defense-in-depth option.
  2. Public guidance ([MDN](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/CSRF), [[web.dev](https://web.dev/articles/fetch-metadata)](https://web.dev/articles/fetch-metadata)) and active community discussion (for example, Go issue [#73626](net/http: add CrossOriginForgeryHandler golang/go#73626)) highlight growing adoption and interest in using Fetch Metadata to reduce CSRF risk.
  3. Early adopters and libraries (e.g., [tower-sec-fetch](https://github.com/matteojoliveau/tower-sec-fetch)) demonstrate practical implementations and demand for canonical guidance.

developers following the OWASP CSRF Cheat Sheet do not currently have OWASP-backed guidance on how to apply Fetch Metadata (Sec-Fetch-*) checks safely and correctly, or how to combine them with existing defenses (SameSite, tokens, Origin/Referer checks).

How should this be resolved?

Add a subsection “Fetch Metadata (Sec-Fetch-*) — an additional defense-in-depth control” under the Defense-in-Depth Techniques section. The subsection should:

  1. Explain the concept
    • What Sec-Fetch-SiteSec-Fetch-ModeSec-Fetch-Dest, and Sec-Fetch-User are and why Sec-Fetch-Site is most relevant for CSRF protection.
  2. Describe recommended policy
    • If Sec-Fetch-Site is present and equals cross-site, reject non-safe state-changing requests (POST/PUT/PATCH/DELETE) unless explicitly whitelisted.
    • Allow same-origin and (optionally) same-site depending on your subdomain trust model.
    • Treat absence of Sec-Fetch-* headers as unknown (legacy UA or non-browser client) and fall back to Origin/Referer and/or CSRF token validation — do not fail open.
  3. Provide a short example to illustrate common patterns:
  4. Recommend rollout guidance
    • Start with a logging / report-only mode to detect legitimate traffic that would be blocked.
    • Monitor coverage and ensure fallbacks cover clients that do not send Sec-Fetch-*.

I already have a PR prepared, so you can assign this issue to me, and I will submit a PR. Thank you!

Metadata

Metadata

Assignees

Labels

ACK_OBTAINEDIssue acknowledged from core team so work can be done to fix it.UPDATE_CSIssue about the update/refactoring of a existing cheat sheet.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions