Spring CSRF protection disabled
Bug Pattern: SPRING_CSRF_PROTECTION_DISABLED
Disabling Spring Security’s CSRF protection is unsafe for standard web applications.
A valid use case for disabling this protection would be a service exposing state-changing operations that is guaranteed to be used only by non-browser clients.
Insecure configuration:
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
}
}
References
Spring Security Official Documentation: When to use CSRF protection
OWASP: Cross-Site Request Forgery
OWASP: CSRF Prevention Cheat Sheet
CWE-352: Cross-Site Request Forgery (CSRF)