为什么checkmarx使用DOMPurify后没有传递XSS漏洞?

Why does checkmarx not passing XSS vulnerability after using DOMPurify?

提问人:Surendranatha Reddy T 提问时间:5/9/2023 更新时间:5/9/2023 访问量:254

问:

我正在使用Checkmarx扫描一个项目的漏洞,我无法在JS文件中使用DOMPurify清除XSS漏洞。

示例代码:

function purifyDOM(tag){
    var dom_purify = DOMPurify.sanitize(tag, {ALLOWED_TAGS: ['tr', 'th', 'td', 'a', 'div', 'table', 'option', 'html', 'i']})
    return dom_purify
}

function attribute_render(data){
   var attribute = data['attribute_path']
   var cleaned_tag = purifyDOM(attribute)
   $('#attributename').html(cleaned_tag)
}

我在扫描报告中看到以下信息。

客户端 DOM 存储的 XSS\Path 11:

应用程序的attribute_render使用 html 在 webapp/ktc_app/static/assets/js/customjs.js 的第 1233 行处将不受信任的数据嵌入到生成的输出中。这些不受信任的数据在没有适当审查或编码的情况下直接嵌入到输出中,使攻击者能够将恶意代码注入输出。

为什么会这样?我可以继续使用其他方法来清除 XSS 漏洞吗?

JavaScript HTML XSS CheckMarx Dompurify

评论


答: 暂无答案