Avoid Veracode CWE-80: Improper Neutralization of Script-Related HTML in jquery htm() method

此生再无相见时 提交于 2019-12-11 12:52:31

问题


I've just completed my first Veracode static scan of an asp.net mvc web application, and Veracode found dozens of CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page flaws.

Nearly all of them involve the use of the jquery html() method. Our pattern is to make a $.ajax() call in javascript, and in the success event display the results of the $.ajax call in an html element, like so:

success: function(data) {
    $('#elementid').html(data);
}

In most cases these $.ajax() calls are to MVC controller methods that return MVC partial views, chock full of html tags and etc.

How would we alter our javascript so that calls like this are not flagged as CWE-80 flaws by Veracode? Can we still do client-side $.ajax calls to controller methods that return blobs of html and pass muster with Veracode?


回答1:


I scheduled a Veracode consultation and learned that Veracode simply marks all $.html() calls as flaws of Medium severity. There are two courses of action open to us:

  1. Mark the flaw as "mitigated" with an explanation, or
  2. Change the code to remove all calls to $.html().

We are choosing to mark all of these flaws as "mitigated."



来源:https://stackoverflow.com/questions/50863812/avoid-veracode-cwe-80-improper-neutralization-of-script-related-html-in-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!