Validate the report-uri value given to CSPHeaderConfiguration#reportBack

Đang mở Phù hợp với người mới
#1,946 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@AzizOuertani đang làm issue này rồi.

Từ ngày 20/11/2026.

  • #1973 của @AzizOuertani — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java
Lĩnh vực
backend

Hướng nghiên cứu

Đọc nhánh xác thực REPORT_URI trong CSPDirective.java và checkValidityForSrc() của RelativeURICSPValue.java để xác nhận liệu nó có từ chối URL tuyệt đối hay không. Thêm các bài kiểm tra cho một URL tuyệt đối không hợp lệ và một đường dẫn mount cspviolation hợp lệ trong wicket-core-tests/src/test/java/org/apache/wicket/csp/CSPDirectiveTest.java. Hoàn tất khi reportBack từ chối các giá trị không tương đối bằng IllegalArgumentException và chấp nhận một đường dẫn mount thông thường.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Java
Star
800
Fork
437
Merge trung bình
21 giờ 36 phút
Pull request đã merge (30 ngày)
167

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của apache/wicket

Tất cả issue của apache/wicket

Issue tương tự

Thêm issue về Java

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.