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:

  1. http://security.coverity.com/document/2013/mar/fixing-xss-a-practical-guide-for-developers.html
  2. https://www.owasp.org/index.php/dom_based_xss_prevention_cheat_sheet

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -