简体   繁体   English

服务器端请求伪造漏洞

[英]Server Side Request Forgery vulnerability

I have a RESTful service controller that requests another RESTful service我有一个 RESTful 服务控制器,它请求另一个 RESTful 服务

@ResponseBody
@RequestMapping(value = "/headerparameters/{instanceId}", method = RequestMethod.DELETE)
public RestContainerFormBean passivizeHeaderParameter(@PathVariable String instanceId) throws GenericException, IOException {

    String url = proactiveURL + "/customerheaders/" + instanceId;
    if(isSecurityCheckOK(url)){
        ResponseEntity<CustomerHeaderParameterBean> response = restTemplate.exchange(url, HttpMethod.DELETE, new HttpEntity<>(new HttpHeaders()), CustomerHeaderParameterBean.class);
        CustomerHeaderParameterBean result = response.getBody();
        setButtonActivity(result);
        l10nOfValue(result);
        return new RestContainerFormBean(result);
    } else{
        throw new IOException();
    }
}

This code can not pass SonarQube policy.此代码无法通过 SonarQube 策略。

Refactor this code to not construct the URL from tainted,重构此代码以不构造受污染的 URL,

User provided data, such as URL parameters, POST data payloads, or cookies, should always be considered untrusted and tainted.用户提供的数据,例如 URL 参数、POST 数据负载或 cookie,应始终被视为不受信任和受污染。 A remote server making requests to URLs based on tainted data could enable attackers to make arbitrary requests to the internal network or to the local file system.远程服务器根据受污染的数据向 URL 发出请求,可能使攻击者能够向内部网络或本地文件系统发出任意请求。

The problem could be mitigated in any of the following ways:可以通过以下任何一种方式缓解该问题:

Validate the user provided data based on a whitelist and reject input not matching.根据白名单验证用户提供的数据并拒绝不匹配的输入。 Redesign the application to not send requests based on user provided data.重新设计应用程序,使其不根据用户提供的数据发送请求。

How can I pass the policy by sticking on REST conventions ?如何通过坚持 REST 约定来传递策略?

使用 UriComponentsBuilder 对 URL 进行编码,而不是使用原始 URL。

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

相关问题 如何修复 spring restTemplate 中的“服务器端请求伪造”问题 - How to fix "Server-Side Request Forgery" issue in spring restTemplate 安全性 - URLConnection 服务器端请求伪造 (SSRF) 和文件泄露 - Security - URLConnection Server-Side Request Forgery (SSRF) and File Disclosure 获取服务器端请求伪造 (SSRF) (CWE ID 918) restTemplate.getForEntity - Getting Server-Side Request Forgery (SSRF) (CWE ID 918) restTemplate.getForEntity 使用 SonarLint 插件和 SonarQube 服务器未检测到 HTTP 请求重定向漏洞 - HTTP request redirections vulnerability does not detect with SonarLint plugin and SonarQube server Web服务和跨站请求伪造 - Webservice and Cross-Site Request Forgery 在Liferay中防止跨站点请求伪造 - Preventing cross-site request forgery in Liferay 计时器替代品,用于测量服务器端的请求率 - Timer alternative to measure request rate on the server side 在服务器端检测到浏览器“将图像另存为...”请求 - Detecting the browser “Save image as…” request in server side 如何在服务器端解压json数据请求? - How to decompress json data request at server side? Retrofit2 - 请求取消的服务器端被忽略 - Retrofit2 - Request canceled server side are ignored
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM