Skip to content

fix: wp-json記事投稿がModSecurity CRSに誤検知ブロックされる問題を修正#4

Open
makoto-kamimura wants to merge 1 commit into
masterfrom
claude/wordpress-auto-update-routine-2dh7fg
Open

fix: wp-json記事投稿がModSecurity CRSに誤検知ブロックされる問題を修正#4
makoto-kamimura wants to merge 1 commit into
masterfrom
claude/wordpress-auto-update-routine-2dh7fg

Conversation

@makoto-kamimura

Copy link
Copy Markdown
Owner

Summary

  • WordPress自動投稿ルーティン(AI Trend Weekly Report / Security Incident Weekly Report / Tech Blog Auto Post)の記事投稿が、複数段落・Mermaid図・URLリンクを含む本文で /wp-json/wp/v2/posts にPOSTすると、手前のnginx + OWASP ModSecurity CRSに403 Forbiddenで誤検知ブロックされることを確認しました
  • 短いテスト投稿は成功する一方、実際の記事本文サイズ(数百〜数千文字、複数の <p>/<a> タグ、日本語の記号など)ではCRSの匿名スコアが ANOMALY_INBOUND(=10) のしきい値を超えてしまい、認証済み(アプリケーションパスワード使用)の正規リクエストまでブロックされていました
  • platform/nginx_data/modsec-rules/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf が空だったため、wp-json REST APIに対する除外設定が一切ない状態でした
  • Authorizationヘッダを伴う POST/PUT に限定し、/wp-json/wp/v2/posts/wp-json/wp/v2/pages (記事・固定ページ書き込みエンドポイント)に対してのみCRS検査を除外するルールを追加しました
    • GET(記事一覧・取得)、認証ヘッダの無い匿名リクエスト、wp-login.phpwp-admin など他のパスは引き続きCRSのフル検査対象のままです

Test plan

  • docker compose up -d --remove-orphans で nginx コンテナを再起動し、設定が反映されることを確認
  • nginx -t 相当のヘルスチェックが通ることを確認(既存の healthcheck で自動検証)
  • 認証済みで /wp-json/wp/v2/posts に複数段落+Mermaid図を含む本文をPOSTし、201 Created になることを確認
  • 認証ヘッダなしの匿名POSTや、wp-login.php へのXSS/SQLiパターンを含むリクエストが引き続きCRSでブロックされることを確認(除外範囲が広すぎないことの確認)

Generated by Claude Code

…coring

Authenticated POST/PUT requests to /wp-json/wp/v2/posts and /pages carry
rich article content (multiple paragraphs, Mermaid diagrams, links) that
was accumulating enough CRS anomaly score to exceed ANOMALY_INBOUND and
get blocked with a 403 before reaching WordPress, even for legitimate
requests authenticated with an application password.

Add a targeted exclusion in REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf
that only skips CRS for POST/PUT to those endpoints when an Authorization
header is present; GET requests, unauthenticated requests, and all other
paths (wp-login.php, wp-admin, etc.) stay fully covered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants