[英]Code injection issue for class.forname in Java during Checkmarx scan
How to resolve this code injection issue for class.forname in Java.如何解决 Java 中 class.forname 的此代码注入问题。 During checkmarx scan I am facing this code injection issue, below is the sample code snippet
在 checkmarx 扫描期间,我面临这个代码注入问题,下面是示例代码片段
StringBuffer xml = new StringBuffer
xml.append("<?xml version=\ "1.0\"encoding=\"utf-8\" ?>");
xml.append("<Response>");
try{
String strpath = request.getParameter("myclass");
If(strpath!= null){
xml.append("<Message>"+strpath+"</Message>");
Class cls = Class.forName(strpath);
strpath = getLocation(cls);
xml.append("<Path>"+strpath+"</Path>");
}
}
catch(Exception err){
strpath = err.getMessage();
}
对于Checkmarx,直接给字符串“strpath”赋值,无需对其进行圣化,使用前需要验证字符串“strpath”,Checkmarx不会看到任何代码注入
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.