RSharma055327 (Community Member) asked a question.

How to fix XSS or use cleansing function here

$(response.Results).each(function (index, element) {

12

if (AFIS.fundName !== 'AFIS Returns') {

13

if (element.language.includes(missingName)) {

14

element.language = element.language.replace(missingName, AFIS.fundName);

15

}

Highlighted is the issue


  • Hi @RSharma055327 (Community Member)​ ,

     

    Veracode Static Analysis reports a flaw of CWE 80 Basic XSS when we can see dynamic data going into the jQuery function, in your example this would likely be "$(response.Results)". It appears though, from the rest of you example that you're not intending this to be HTML but instead this is an array with objects?

    In this case we'd recommend replacing that with Array.forEach ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach ), in your example:

     

    response.Results.forEach(function (element) {

    if (AFIS.fundName !== 'AFIS Returns') {

    if (element.language.includes(missingName)) {

    element.language = element.language.replace(missingName, AFIS.fundName);

    }

    }

    });

     

    Thank you,

    Boy Baukema

    Expand Post

Topics (3)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.