简体   繁体   English

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

[英]Getting Server-Side Request Forgery (SSRF) (CWE ID 918) restTemplate.getForEntity

I am using restTemplate for synchronous inter-service communication in a microservices architecture.我正在使用restTemplate在微服务架构中进行同步服务间通信。

When we completed Veracode scan, we are getting Server-Side Request Forgery (SSRF) (CWE ID 918) in getForEntity method.当我们完成Veracode扫描时,我们在getForEntity方法中获取Server-Side Request Forgery (SSRF) (CWE ID 918)

restTemplate.getForEntity(URL, Entity.class);

Not sure why I am getting this SSRF issue?.不知道为什么我会收到这个SSRF问题?
What would be the possible fix for this?对此有什么可能的解决方法?

I have fixed this issue by build the URL using UriComponents before using it in restTemplate.我已经通过在 restTemplate 中使用之前使用 UriComponents 构建 URL 解决了这个问题。

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

Please refer this link to use UriComponents https://www.baeldung.com/spring-uricomponentsbuilder请参考此链接以使用 UriComponents https://www.baeldung.com/spring-uricomponentsbuilder

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM