2
0

exploits.adoc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. = Exploit Protection Migrations
  2. :spring-security-reference-base-url: https://docs.spring.io/spring-security/reference
  3. The 5.8 migration guide contains several steps for
  4. ifdef::spring-security-version[]
  5. {spring-security-reference-base-url}/5.8/migration/servlet/exploits.html[exploit protection migrations] when updating to 6.0.
  6. endif::[]
  7. ifndef::spring-security-version[]
  8. exploit protection migrations when updating to 6.0.
  9. endif::[]
  10. You are encouraged to follow those steps first.
  11. The following steps relate to how to finish migrating exploit protection support.
  12. == Defer Loading CsrfToken
  13. In Spring Security 5.8, the default `CsrfTokenRequestHandler` for making the `CsrfToken` available to the application is `CsrfTokenRequestAttributeHandler`.
  14. The default for the field `csrfRequestAttributeName` is `null`, which causes the CSRF token to be loaded on every request.
  15. In Spring Security 6, `csrfRequestAttributeName` defaults to `_csrf`.
  16. If you configured the following only for the purpose of updating to 6.0, you can now remove it:
  17. requestHandler.setCsrfRequestAttributeName("_csrf");
  18. == Protect against CSRF BREACH
  19. In Spring Security 5.8, the default `CsrfTokenRequestHandler` for making the `CsrfToken` available to the application is `CsrfTokenRequestAttributeHandler`.
  20. `XorCsrfTokenRequestAttributeHandler` was added to allow opting into CSRF BREACH support.
  21. In Spring Security 6, `XorCsrfTokenRequestAttributeHandler` is the default `CsrfTokenRequestHandler` for making the `CsrfToken` available.
  22. If you configured the `XorCsrfTokenRequestAttributeHandler` only for the purpose of updating to 6.0, you can remove it completely.
  23. [NOTE]
  24. ====
  25. If you have set the `csrfRequestAttributeName` to `null` in order to opt out of deferred tokens, or if you have configured a `CsrfTokenRequestHandler` for any other reason, you can leave the configuration in place.
  26. ====
  27. == CSRF BREACH with WebSocket support
  28. In Spring Security 5.8, the default `ChannelInterceptor` for making the `CsrfToken` available with xref:servlet/integrations/websocket.adoc[WebSocket Security] is `CsrfChannelInterceptor`.
  29. `XorCsrfChannelInterceptor` was added to allow opting into CSRF BREACH support.
  30. In Spring Security 6, `XorCsrfChannelInterceptor` is the default `ChannelInterceptor` for making the `CsrfToken` available.
  31. If you configured the `XorCsrfChannelInterceptor` only for the purpose of updating to 6.0, you can remove it completely.