javascript - Fortify : DOM based cross site scripting -
i have fortify vulnerability cross site scripting : dom.
in application(asp.net) dynamically constructing html , assign div tag complaining issue.
str += '<div id="' + itemid + '"'; if(somecondition==true){ str += 'class="' + somevalue + '"'; } if (somevalue == 0) { str += ' style="position: relative; '; str += 'top:0; ' ; str += 'visibility: inherit; ' }else{ str += ' style="position: absolute; '; str += 'top: ' + itemy + '; ' ; str += 'width: ' + w + '; '; str += 'height: ' + h + '; ' str += 'visibility: inherit; '
....
......
after constructing html, assigning div tag below.
var newdiv = document.createelement('div'); document.getelementsbytagname('body').item(0).appendchild(newdiv); newdiv.innerhtml = str;
while assigning str newdiv fortify showing cross site scripting : dom issue.
to fix issue tried using html encoder didnt work. please share inputs resolve issue.
simply html encoding data not sufficient. make sure unsafe data encoded context in appears within document. see following articles, discuss various contexts , importance of context-sensitive encoding:
Comments
Post a Comment