javascript - XSS fix for JSON in JSP page -
during static analysis getting xss vulnerability in jsp code. forwarding request jsp page servlet. requets contains json string. in jsp page, retrieving appid value json object. use appid value retrive further info using xhr calls.
<script type="text/javascript"> var appid; // appcontext json string var appcontextstr=<%=request.getparameter("appcontext")%>; // xss vulenrability detected if(appcontextstr!= null || !appcontextstr.equals("")){ appid= appcontextstr.appid; } </script> how address xss issue?
you can urlencode <%=request.getparameter("appcontext")%> before assigning appcontextstr, if value not meant have non-alphanumeric symbols.
the vulnerability fire if (not user himself) can specify appcontext value like
"asdsa; alert('busted')" evil javascript instead of alert()
that said, not user-controlled json exploitable yet static analysis tools stil whine remote possibilities.
Comments
Post a Comment