This is my filer config in web.xml
<filter>
<filter-name>CSRFPreventionFilter</filter-name>
<filter-class>org.apache.catalina.filters.CsrfPreventionFilter</filter-class>
<init-param>
<param-name>entryPoints</param-name>
<param-value>/login<param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CSRFPreventionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
Am I missing something? Are any code-changes necessary to enable csrf protection in tomcat
Note that a 403 is the CSRFPreventionFilter response if a nonce is not provided and the filter expects one.
I don't know the current state of CSRFPreventionFilter, but according to this thread you need to specify each entryPoint resource individually (no wildcards) - or have the filter apply to a path that does not include /login
So:
<filter>
<filter-name>CSRFPreventionFilter</filter-name>
<filter-class>org.apache.catalina.filters.CsrfPreventionFilter</filter-class>
<init-param>
<param-name>entryPoints</param-name>
<param-value>/login/login.html,/login/image.png,/login/style.css</param-value>
</init-param>
</filter>
Or:
<filter-mapping>
<filter-name>CSRFPreventionFilter</filter-name>
<url-pattern>/csrf/*</url-pattern>
</filter-mapping>
Update Dec 2012:
Tomcat 7.0.32 fixes a security vulnerability in CSRFPreventionFilter
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With