Zum Inhalt springen

Disabled CSRF (ARCH4125)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key java.security.disabled-csrf · Severity warning · Category security · CWE CWE-352

Disabling CSRF protection on cookie-based sessions lets attackers trigger state-changing requests from a victim’s browser. Keep CSRF protection enabled for browser-based sessions.

@Bean
SecurityFilterChain chain(HttpSecurity http) throws Exception {
http.csrf(csrf -> csrf.disable()); // CSRF off
return http.build();
}
@Bean
SecurityFilterChain chain(HttpSecurity http) throws Exception {
http.csrf(csrf -> csrf
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()));
return http.build();
}

Keep token-based CSRF protection enabled for cookie-session apps instead of disabling it.