1 Reply Latest reply: Dec 18, 2012 1:43 PM by gimbal2 RSS

    JSF 1.2 and CSRF (Cross Site Request Forgery) protection

      Hi All

      My webapp uses (among other technologies like JSP, Ajax, Dojo etc) JSF v1.2 on Webshere 7.0.

      I've been fixing security issues in the code recently - in particular Cross Site Request Forgery (CSRF) vulnerabilities. The suggested approach to combat CSRF is to embed a hidden unique token in your form (and also store this same token in the session). In the controller logic (i.e that handles the form's POST) we then check that the session and request token match. I've used this in my JSP's to combat CSRF successfullu. Basically I have a filter which executes before the form loads. This filter creates the unique token and stores in request and session and so on ..

      Now for JSF 1.2 ...

      I'm wondering how I do this in JSF v1.2 ? Would any one have an code samples or resource they could point me towards ? Is there a filter mechanism we can employ or some callback on the post ?
      One idea I had is that to populate to form with the hidden token I would do (in the form):

      <h:inputHidden id="jsfSecurityToken" value="#{myBean.securityToken}"/>

      In "myBean.java" I have a getSecurityToken method which
      a) creates the token
      b) stores it into the request
      c) stores it into the session

      BUT I don't know how/where on the post I can CHECK if these values match

      Page 40/41 of http://turbomanage.files.wordpress.com/2009/10/securing-jsf-applications-against-owasp-top-ten-color.pdf mentions "isPostBack" but I'm not sure how to use this.

      Any help would be great

      Thanks - Ronan