Aller au contenu

Disabled CSRF (ARCH4125)

Ce contenu n’est pas encore disponible dans votre langue.

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.