CVE-2021-27693 (published 2022-09-02T18:15Z)

Server-side Request Forgery (SSRF) vulnerability in PublicCMS before 4.0.202011.b via /publiccms/admin/ueditor when the action is catchimage.

CVSS v3 base score: 9.8, CRITICAL (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-918
cwe_name: Server-Side Request Forgery (SSRF)
description: The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.
extended_description: By providing URLs to unexpected hosts or ports, attackers can make it appear that the server is sending the request, possibly bypassing access controls such as firewalls that prevent the attackers from accessing the URLs directly. The server can be used as a proxy to conduct port scanning of hosts in internal networks, use other URLs such as that can access documents on the system (using file://), or use other protocols such as gopher:// or tftp://, which may provide greater control over the contents of requests.
         

Fix information:
repo_url: https://github.com/sanluan/PublicCMS
commit_details: repo_url: https://github.com/sanluan/PublicCMS
author: sanluan
author_date: 2021-02-24 10:53:02+08:00
msg: https://github.com/sanluan/PublicCMS/issues/51
repository: repo_url: https://github.com/sanluan/PublicCMS
repo_name: sanluan/PublicCMS
description: More than 2 million lines of code modification continuously iterated for 7 years to modernize java cms, easily supporting tens of millions of data, tens of millions of PV; Support static, server side includes; Currently has 0.0005% of the world's users (w3techs provided data), language support in Chinese, Japanese, English
repo_language: Java
owner: sanluan
file_changes: filename: UeditorAdminController.java
change_type: ModificationType.MODIFY
diff: @@ -218,7 +218,8 @@ public class UeditorAdminController {
                         BufferedInputStream inputStream = new BufferedInputStream(entity.getContent());
                         FileType fileType = FileTypeDetector.detectFileType(inputStream);
                         String suffix = fileType.getCommonExtension();
-                        if (CommonUtils.notEmpty(suffix)) {
+                        if (null != fileType.getMimeType() && fileType.getMimeType().startsWith("image/")
+                                && CommonUtils.notEmpty(suffix)) {
                             String fileName = CmsFileUtils.getUploadFileName(suffix);
                             String filePath = siteComponent.getWebFilePath(site, fileName);
                             CmsFileUtils.copyInputStreamToFile(inputStream, filePath);
@@ -238,9 +239,13 @@ public class UeditorAdminController {
                     }
                     EntityUtils.consume(entity);
                 }
-                Map<String, Object> map = getResultMap(true);
-                map.put("list", list);
-                return map;
+                if (list.isEmpty()) {
+                    return getResultMap(false);
+                } else {
+                    Map<String, Object> map = getResultMap(true);
+                    map.put("list", list);
+                    return map;
+                }
             }
         } catch (Exception e) {
             log.error(e.getMessage(), e);

programming_language: Java