datasette PR #2689: トークンベースのCSRF保護をSec-Fetch-Siteヘッダー保護に置き換え
本文の状態
日本語全文を表示中
詳細モードで約2分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
Simon Willison Blog
Datasetteプロジェクトが、従来のCSRFトークン方式をSec-Fetch-Siteヘッダーによる保護に置き換えるプルリクエストを公開した。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
datasette PR #2689: トークンベースのCSRFからSec-Fetch-Siteヘッダー保護へ置換
Datasetteは、私のasgi-csrf Pythonライブラリを使用して実装されたCSRFトークンを用いて、長年にわたりCSRF(Cross-Site Request Forgery:クロスサイトリクエストフォージェリ)攻撃から保護してきました。これらは扱いがやや面倒なものであり、テンプレート内のフォームに<input type="hidden" name="_csrf" value="...">タグを散りばめ、ブラウザ外から呼び出されることを意図したAPIに対してはCSRF保護を selectively(選択的に)無効化する必要があります。
私は、Filippo Valsordaによるこの研究を注視してきました。これは2025年8月の詳細なエッセイで説明され、その同じ月にGo 1.25の一部として実装されました。
私は今、Datasetteにも同様の改変を適用しました。以下はPR(Pull Request:プルリクエスト)の説明です。Claude Codeが多くの作業を行い(10回のコミットにわたって、私の厳密な指導のもと、GPT-5.4によるクロスレビューを経て)ましたが、私はこれらのPR説明を手書きで記述し始めることにしました。その理由の一部分は、より簡潔にすることであり、また自分自身を誠実に保つための演習としても行っています。
- Go 1.25およびFilippo Valsordaによるこの研究に触発された、新しいCSRF保護ミドルウェア。これは古いトークンベースのCSRF保護を置き換えます。
- テンプレート内のすべての
<input type="hidden" name="_csrf" value="...">のインスタンスを削除しました。これらはもはや不要です。
- datasette/hookspecs.pyで定義された
def skip_csrf(datasette, scope):プラグインフック、およびそのドキュメントとテストを削除しました。
- 新しいアプローチについて説明するよう、CSRF保護のドキュメントを更新しました。
- CSRF 変更に関するアップグレードガイドを記載しました。
原文を表示
datasette PR #2689: Replace token-based CSRF with Sec-Fetch-Site header protection
Datasette has long protected against CSRF attacks using CSRF tokens, implemented using my asgi-csrf Python library. These are something of a pain to work with - you need to scatter forms in templates with `` lines and then selectively disable CSRF protection for APIs that are intended to be called from outside the browser.
I've been following Filippo Valsorda's research here with interest, described in this detailed essay from August 2025 and shipped as part of Go 1.25 that same month.
I've now landed the same change in Datasette. Here's the PR description - Claude Code did much of the work (across 10 commits, closely guided by me and cross-reviewed by GPT-5.4) but I've decided to start writing these PR descriptions by hand, partly to make them more concise and also as an exercise in keeping myself honest.
New CSRF protection middleware inspired by Go 1.25 and this research by Filippo Valsorda. This replaces the old CSRF token based protection.
Removes all instances of in the templates - they are no longer needed.
Removes the def skip_csrf(datasette, scope): plugin hook defined in datasette/hookspecs.py and its documentation and tests.
Updated CSRF protection documentation to describe the new approach.
Upgrade guide now describes the CSRF change.
Tags: csrf, security, datasette, ai-assisted-programming
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み