Validate the report-uri value given to CSPHeaderConfiguration#reportBack

Abierto Apto para principiantes
#1,946 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@AzizOuertani ya está trabajando en esto.

Desde el 20/11/2026.

  • #1973 de @AzizOuertani — abierto

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
backend

Línea de trabajo

Lee la rama de validación de REPORT_URI en CSPDirective.java y checkValidityForSrc() de RelativeURICSPValue.java para confirmar si rechaza las URL absolutas. Añade pruebas para una URL absoluta no válida y una ruta de montaje cspviolation válida en wicket-core-tests/src/test/java/org/apache/wicket/csp/CSPDirectiveTest.java. Se considera terminado cuando reportBack rechaza los valores no relativos con IllegalArgumentException y acepta una ruta de montaje normal.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Java
Estrellas
800
Forks
437
Merge medio
21 h 36 min
PR fusionados (30 d)
167

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/wicket

Todos los issues de apache/wicket

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.