获取服务器端请求伪造(SSRF)(CWE ID 918)restTemplate.getForEntity



我使用restTemplate在微服务架构中进行同步服务间通信。

当我们完成Veracode扫描时,我们得到的是getForEntity方法中的Server-Side Request Forgery (SSRF) (CWE ID 918)

restTemplate.getForEntity(URL, Entity.class);

不确定我为什么会收到这个SSRF问题
对此可能的解决方案是什么?

我已经解决了这个问题,在restTemplate中使用UriComponents之前,先构建URL。

UriComponents uriComponents = UriComponentsBuilder.newInstance()
.scheme("http").host("www.yourdomain.com").path("/yourPath").build();

请参阅此链接以使用UriComponentshttps://www.baeldung.com/spring-uricomponentsbuilder

最新更新