Validate the report-uri value given to CSPHeaderConfiguration#reportBack

未关闭 适合新手
#1,946 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@AzizOuertani 已经在做这个了。

开始于 2026年11月20日。

  • #1973 来自 @AzizOuertani —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
84/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
backend

调研方向

阅读CSPDirective.java中REPORT_URI的验证分支和RelativeURICSPValue.java的checkValidityForSrc(),确认它是否会拒绝绝对 URL。在wicket-core-tests/src/test/java/org/apache/wicket/csp/CSPDirectiveTest.java中添加针对无效绝对 URL 和有效cspviolation挂载路径的测试。完成标准是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 分钟
30 天内合并 PR
167

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/wicket 的其他 Issue

查看 apache/wicket 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。