I am using struts2 jquery grid in my current project.The dataType
used in jquery grid is json
. Everything works like charm. There was a security audit of my application and they pinpointed the JSON Hijacking vulnerability. I searched the internet for mitigating the json hijacking in general & solution in struts2. I quite fing good documentation.
Json Hijacking
Prevent Struts2 from JSON Hijacking
I used the prefix param set to true in json result type in struts.xml. All is working fine , i got the json data prefixed with {}&&. As described in Link 2 this is used to mitigate the json hijacking.
The problem i faced is that jQuery Grid is not able to load Data.
My struts.xml
<action name="myjson" class="action.JsonTable">
<result type="json">
<param name="prefix">true</param>
</result>
The grid is not able to populate.Wen i remove <param name="prefix">true</param>
from the action defnition, everything works fine. But it is vulnerable :(