Csrf Defense Mechanism Shift (Token-Based To Sec-Fetch-Site Header-Based)
Sources: 1 • Confidence: High • Updated: 2026-04-15 03:46
Key takeaways
- Datasette PR #2689 replaces CSRF token-based protection with middleware that uses Sec-Fetch-Site header-based protection inspired by Go 1.25 and Filippo Valsorda's research.
- For the Datasette CSRF approach change, Claude Code produced much of the PR work across 10 commits with close guidance and cross-review by GPT-5.4.
- The author intends to write PR descriptions by hand going forward to keep them more concise and to stay honest.
- Under the previous token-based CSRF system, templates needed hidden csrftoken inputs and external-facing APIs often required selectively disabling CSRF protection.
- Filippo Valsorda's CSRF research was described in a detailed essay from August 2025 and was shipped as part of Go 1.25 in August 2025.
Sections
Csrf Defense Mechanism Shift (Token-Based To Sec-Fetch-Site Header-Based)
- Datasette PR #2689 replaces CSRF token-based protection with middleware that uses Sec-Fetch-Site header-based protection inspired by Go 1.25 and Filippo Valsorda's research.
- Under the previous token-based CSRF system, templates needed hidden csrftoken inputs and external-facing APIs often required selectively disabling CSRF protection.
- Filippo Valsorda's CSRF research was described in a detailed essay from August 2025 and was shipped as part of Go 1.25 in August 2025.
Ai-Assisted Implementation And Review Workflow
- For the Datasette CSRF approach change, Claude Code produced much of the PR work across 10 commits with close guidance and cross-review by GPT-5.4.
Maintainer Communication Norms For Pr Descriptions
- The author intends to write PR descriptions by hand going forward to keep them more concise and to stay honest.
Unknowns
- What are the precise security guarantees and threat model of the Sec-Fetch-Site-based CSRF middleware compared to the prior token-based approach in Datasette?
- What is the expected compatibility and behavior across browsers/clients that may omit or manipulate Sec-Fetch-Site headers (including non-browser HTTP clients)?
- What are the specific upgrade and integration implications for existing Datasette templates, plugins, hooks, and external API patterns that previously relied on token-based CSRF or selective disabling?
- Were any automated tests, security tests, or real-world incidents used to validate the new CSRF middleware behavior, and what were the results?
- Will the described AI-assisted development and cross-review approach become a consistent maintainership practice for Datasette changes, and how will it be documented for contributors/reviewers?