Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Default passkey pages fail with NullPointerException when CSRF is disabled

Aperta Adatta ai principianti
#19,984 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Inizia con WebAuthnConfigurer e DefaultWebAuthnRegistrationPageGeneratingFilter, dove l’issue individua le ricerche di un token CSRF nullo; leggi i test corrispondenti in WebAuthnConfigurerTests. Riproduci il problema con CSRF disabilitato e le passkey abilitate, poi verifica che /login e /webauthn/register vengano renderizzati senza un header CSRF né un campo nascosto quando non è presente alcun token.

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

Descrizione

status: waiting-for-triage

Describe the bug

With passkeys enabled and CSRF protection disabled, the default login page and the default passkey registration page fail with a NullPointerException:

  • WebAuthnConfigurer gives DefaultLoginPageGeneratingFilter a header resolver that reads the CsrfToken request attribute and calls getHeaderName() on it without checking for null.
  • DefaultWebAuthnRegistrationPageGeneratingFilter does the same when it renders the CSRF header for its script and the hidden input in each passkey's delete form.

The other default pages (login, logout and one-time token) already leave the token out when there is none.

To Reproduce

http
    .formLogin(Customizer.withDefaults())
    .csrf(AbstractHttpConfigurer::disable)
    .webAuthn((webAuthn) -> webAuthn.rpId("example.com"));

Then GET /login, or GET /webauthn/register as a signed-in user:

java.lang.NullPointerException: Cannot invoke "org.springframework.security.web.csrf.CsrfToken.getHeaderName()" because "csrfToken" is null
	at org.springframework.security.config.annotation.web.configurers.WebAuthnConfigurer.lambda$configure$2(WebAuthnConfigurer.java:208)
java.lang.NullPointerException: Cannot invoke "org.springframework.security.web.csrf.CsrfToken.getHeaderName()" because "csrfToken" is null
	at org.springframework.security.web.webauthn.registration.DefaultWebAuthnRegistrationPageGeneratingFilter.renderCsrfHeader(DefaultWebAuthnRegistrationPageGeneratingFilter.java:130)
	at org.springframework.security.web.webauthn.registration.DefaultWebAuthnRegistrationPageGeneratingFilter.doFilterInternal(DefaultWebAuthnRegistrationPageGeneratingFilter.java:88)

This affects 7.0.x, 7.1.x and main.

Expected behavior

Both pages render without a CSRF header or hidden input, as the other default pages do.

Sample

The configuration above is the whole reproduction; the pull request that fixes this adds it as a test in WebAuthnConfigurerTests.

Lingua principale
Java
Stelle
9.7k
Fork
6.4k
Merge medio
2g 2h
PR unite (30g)
54

Preparare l'ambiente

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 spring-projects/spring-security

Tutte le issue di spring-projects/spring-security

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.