I have an application build on top of Mojarra 2.1.20 (package com.sun.faces, RI for JSF 2.2 specification). I have a context param javax.faces.STATE_SAVING_METHOD with value as server specified in my application deployment descriptor file web.xml
JSF is injecting the following ViewState hidden element on my post login page
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="random_number1:random_number2" autocomplete="off" />
The hidden element has value in some random number format and separated by a colon. Since STATE_SAVING_METHOD is server, the actual ViewState in my case is getting stored on the server. But the client is just getting the unique ViewState identifier or random numbers from the server. My understanding is that when user submits a form with this hidden element, the server extracts these random numbers, identifies the actual ViewState from these numbers and then processes the request and sends back the response to the client/user.
Based on the above understandings, I have following queries on the ViewState and its vulnerabilities-
Why two colon separated random numbers instead of one? What these two colon separated random numbers represents? What autocomplete="off" means?
Does these server generated random number map to actual ViewState stored on the server? Is this understanding correct?
Are these server generated random numbers already in encrypted format? Is encryption required on these random numbers to potentially avoid data leak and other vulnerabilities in the application?
How to encrypt these random numbers in my case when ViewState is saved on server?
Could we somehow avoid injection of the element in sources without getting displayed as hidden element?