问题描述
我在微服务架构中使用 restTemplate
进行同步服务间通信。
当我们完成 Veracode
扫描后,我们在 Server-Side Request Forgery (SSRF) (CWE ID 918)
方法中得到 getForEntity
。
restTemplate.getForEntity(URL,Entity.class);
不知道为什么我会遇到这个 SSRF
问题?。
对此有什么可能的解决方法?
解决方法
我已通过在 restTemplate 中使用 URL 之前使用 UriComponents 构建 URL 来解决此问题。
UriComponents uriComponents = UriComponentsBuilder.newInstance()
.scheme("http").host("www.yourdomain.com").path("/yourPath").build();
请参考此链接以使用 UriComponents https://www.baeldung.com/spring-uricomponentsbuilder