Why AI tools produce this: AI coding tools generate this anti-pattern by default, it appears in a large share of AI-written auth code.
Why this matters
With CSRF off, an attacker can forge state-changing requests that a logged-in victim's browser submits with their session cookie (CWE-352). This is one of the most common AI-generated Spring mistakes: csrf().disable() is pasted in to "make the API work" and never removed.
Keep CSRF protection enabled. For a stateless API authenticated with bearer tokens (not cookies), scope it instead (e.g. ignore specific paths or use a CookieCsrfTokenRepository) rather than disabling it globally.
If a finding is a genuine false positive, scope the suppression to the exact line and leave a reason, never disable the rule project-wide. Disable directives are line-scoped by design.