Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 空字符串值上的Veracode XSS_Javascript_Jsp_Xss_Veracode - Fatal编程技术网

Javascript 空字符串值上的Veracode XSS

Javascript 空字符串值上的Veracode XSS,javascript,jsp,xss,veracode,Javascript,Jsp,Xss,Veracode,代码扫描通过后。我已报告我的jsp中存在CWE ID 80 for XSS漏洞的XSS问题: <%@ attribute name="styleId"%> ... document.getElementById("${styleId}").value=""; (XSS here) ... document.getElementById(“${styleId}”).value=”“;(这里是XSS) 我不明白是什么问题在哪里?我必须转义空字符串吗?或者styleId或者两者都有?

代码扫描通过后。我已报告我的jsp中存在CWE ID 80 for XSS漏洞的XSS问题:

<%@ attribute name="styleId"%>
...
document.getElementById("${styleId}").value=""; (XSS here)

...
document.getElementById(“${styleId}”).value=”“;(这里是XSS)
我不明白是什么问题在哪里?我必须转义空字符串吗?或者styleId或者两者都有?
我必须使用EASPI.encodeForHTML吗?

这里的问题是styleId可以引入s。 因此,您必须使用js的规则来转义styleId。 因此,我添加了自定义标记库 在util.tag中

<function>
        <name>escapeJavaScript</name>
        <function-class>org.apache.commons.lang.StringEscapeUtils</function-class>
        <function-signature>java.lang.String escapeJavaScript( java.lang.String )</function-signature>
    </function>

逃逸脚本
org.apache.commons.lang.StringEscapeUtils
java.lang.String escapeJavaScript(java.lang.String)
然后


...
document.getElementById(“${util:escapeJavaScript(styleId)”).value=”“;
下一次扫描后,问题得到了解决

<%@ attribute name="styleId"%>
<%@ taglib prefix="util" uri="http://tags/util" %>
...
document.getElementById("${util:escapeJavaScript(styleId)").value="";