我正在使用 restTemplate
在微服务架构中进行同步服务间通信。
当我们完成 Veracode
扫描时,我们在 getForEntity
方法中收到服务器端请求伪造 (SSRF) (CWE ID 918)
。
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
关于java - 获取服务器端请求伪造 (SSRF)(CWE ID 918)restTemplate.getForEntity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65679327/