zoukankan      html  css  js  c++  java
  • 关于SonarCloud检查到了Vulnerability

    关于SonarCloud检查到了Vulnerability

    Server-side requests should not be vulnerable to forging attacks

    User supplied(提供) data, such as URL parameters, POST data payloads(荷载), or cookies, should always be considered untrusted and tainted(受污染的). Performing(履行的) requests from user-controlled data could allow attackers to make arbitrary(任意的) requests on the internal network or to change their original meaning and thus(因此) to retrieve(找回) or delete sensitive information.

    The problem could be mitigated(减轻) in any of the following ways:

    • Validate the user provided data, such as the URL and headers, used to construct the request.
    • Redesign the application to not send requests based on user provided data.

    Noncompliant Code Example

    const request = require('request');
    
    function ssrf(req, res) {
      const url = req.query.url;
    
      request(url, callback); // Noncompliant
    }
    

    Compliant(应允的) Solution

    Validate the url with an allowlist:

    const request = require('request'); 
    
    function ssrf(req, res) {
      const url = req.query.url;
    
      if(url.startsWith("https://www.trustedwebsite.com/route/?query=")) {
        request(url, callback); // Compliant
      }
    }
    

    今天回过头来编辑这个错误,因为没有解决,所以我是在后端把restful Api形式改掉了. 什么是restful api呢? http://www.ruanyifeng.com/blog/2014/05/restful_api.html
  • 相关阅读:
    Java实现八大排序算法
    Java实现二分查找算法
    Win10下通过IIS调试ASP程序遇到的问题和解决方案
    Nginx几种负载均衡算法及配置实例
    Java解决CSRF问题
    Nginx Https配置不带www跳转www
    面试中的Https
    面试中的DNS
    java系列视频教程下载
    关于Mysql DATE_FORMAT() 日期格式
  • 原文地址:https://www.cnblogs.com/hujesse4/p/15533412.html
Copyright © 2011-2022 走看看