-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
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-origin, same-site, none, cross-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:
- 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. - 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.
- 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:
- Explain the concept
- What
Sec-Fetch-Site,Sec-Fetch-Mode,Sec-Fetch-Dest, andSec-Fetch-Userare and whySec-Fetch-Siteis most relevant for CSRF protection.
- What
- Describe recommended policy
- If
Sec-Fetch-Siteis present and equalscross-site, reject non-safe state-changing requests (POST/PUT/PATCH/DELETE) unless explicitly whitelisted. - Allow
same-originand (optionally)same-sitedepending on your subdomain trust model. - Treat absence of
Sec-Fetch-*headers as unknown (legacy UA or non-browser client) and fall back toOrigin/Refererand/or CSRF token validation — do not fail open.
- If
- Provide a short example to illustrate common patterns:
- 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!