我使用的是一个方法,它调用另一个REST API从DB检索ID。当我对类运行veracode扫描时,我在下面的代码行得到了安全缺陷“服务器端请求伪造”。
response = resttemplate.getForEntity(resturl, String.class);不确定如何解决此问题。任何帮助都是非常感谢的。下面是该方法的完整代码。
public static String getIDFromDB(String resturl) {
String id = null;
RestTemplate resttemplate = new RestTemplate();
ResponseEntity<String> response = new ResponseEntity<>(HTTPStatus.OK)
try {
response = resttemplate.getForEntity(resturl, String.class);
if (response.getStatusCode == HTTPStatus.OK && response.getBody.trim() != null) {
id = response.getBody.trim() ;
}
} Catch(Exception e) {
log.error("failed to get msgID: {}", e);
}
}发布于 2020-10-21 05:42:50
这是因为您允许在代码中完全传递resturl,从而使攻击者能够绕过该URL并将其路由到其预期目标。
为了避免这种情况,应该在配置文件或dB中外部化并引用具有域的URL和具有操作名称的应用程序上下文
https://stackoverflow.com/questions/64453597
复制相似问题