The protection against cross-site request forgery is switched off
What it finds
http.csrf().disable() and its lambda forms turn off Spring Security's protection against cross-site request forgery: another site can then make a logged-in browser send requests that change state, with the user's cookies attached.
For an API that takes no cookies, only tokens in headers, this is safe, which the rule cannot see, so it is not in the default tier.
From the rule's source, csrf_disabled.rs.
class Security { void configure(Http http) throws Exception { http.csrf().disable();tx0 reports: the protection against cross-site request forgery is turned off http.csrf(csrf -> csrf.disable());tx0 reports: is turned off http.csrf(Configurer::disable);tx0 reports: is turned off http.csrf(csrf -> csrf.ignoringRequestMatchers("/webhook")); http.cors().disable(); }} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/java:forgery-protection-off" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:forgery-protection-off] reason="..."tx0 explain tx0/java:forgery-protection-off shows the same in the terminal. Found a false positive? Report it.