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

问题描述

我在微服务架构中使用 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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...