Validate the report-uri value given to CSPHeaderConfiguration#reportBack

オープン 初心者向け
#1,946 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@AzizOuertani がすでに取り組んでいます。

2026年11月20日 から。

  • #1973 @AzizOuertani による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
84/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java
領域
backend

調査の方向性

絶対URLを拒否するか確認するため、CSPDirective.javaのREPORT_URI検証分岐とRelativeURICSPValue.javaのcheckValidityForSrc()を読みます。無効な絶対URLと有効なcspviolationマウントパスのテストをwicket-core-tests/src/test/java/org/apache/wicket/csp/CSPDirectiveTest.javaに追加します。reportBackが相対値でない値をIllegalArgumentExceptionで拒否し、通常のマウントパスを受け入れれば完了です。

索引モデルが issue の本文から書いたものです。

説明

good first issue

CSPHeaderConfiguration#reportBack(String mountPath) adds a RelativeURICSPValue to the report-uri directive. The directive's checkValueForDirective returns as soon as it sees a RelativeURICSPValue, so the value is never checked. Passing an absolute URL or a malformed path by mistake is accepted silently and produces a CSP header the browser can't use.

Where

  • wicket-core/src/main/java/org/apache/wicket/csp/CSPDirective.java, the REPORT_URI constant's checkValueForDirective: the if (value instanceof RelativeURICSPValue) { return; } branch.
  • wicket-core/src/main/java/org/apache/wicket/csp/RelativeURICSPValue.java already has checkValidityForSrc(), which resolves the value against https://example.com/. The original report suggests calling it from the branch above. Check whether it actually rejects an absolute URL like https://evil.example/report; the report says it should be rewritten as well.

Done when

  • reportBack throws an IllegalArgumentException for a value that isn't a relative path, and still accepts a normal mount path like cspviolation.
  • Tests for both cases in wicket-core-tests/src/test/java/org/apache/wicket/csp/CSPDirectiveTest.java.

Background

Originally reported as WICKET-7015 (Wicket 9.12). The reporter included the proposed change in the ticket.


Part of #1945. This issue is meant for a first contribution to Wicket. To work on it, leave a comment so others know; a claim without a pull request lapses after two weeks. Questions are welcome, here on the issue or on [email protected]. Start your branch from master, and see Send a pull request to Wicket for building and testing.

主要言語
Java
スター
800
フォーク
437
平均マージ
21時間 36分
マージ済み PR(30日)
167

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/wicket のほかの issue

apache/wicket の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。