Validate the report-uri value given to CSPHeaderConfiguration#reportBack

Aperta Adatta ai principianti
#1,946 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@AzizOuertani ci sta già lavorando.

Dal 20/11/2026.

  • #1973 di @AzizOuertani — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
java
Ambito
backend

Direzione di ricerca

Leggi il ramo di convalida di REPORT_URI in CSPDirective.java e checkValidityForSrc() di RelativeURICSPValue.java per verificare se rifiuta gli URL assoluti. Aggiungi test per un URL assoluto non valido e un percorso di mount cspviolation valido in wicket-core-tests/src/test/java/org/apache/wicket/csp/CSPDirectiveTest.java. Il lavoro è completo quando reportBack rifiuta i valori non relativi con IllegalArgumentException e accetta un normale percorso di mount.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Java
Stelle
800
Fork
437
Merge medio
21h 36m
PR unite (30g)
167

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di apache/wicket

Tutte le issue di apache/wicket

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.