GHSA-7GC4-R5JR-9HXV

Vulnerability from github – Published: 2022-10-25 21:02 – Updated: 2022-10-27 18:38
VLAI
Summary
Gin-vue-admin subject to Remote Code Execution via file upload vulnerability
Details

Impact

Gin-vue-admin < 2.5.4 has File upload vulnerabilities。 File upload vulnerabilities are when a web server allows users to upload files to its filesystem without sufficiently validating things like their name, type, contents, or size. Failing to properly enforce restrictions on these could mean that even a basic image upload function can be used to upload arbitrary and potentially dangerous files instead. This could even include server-side script files that enable remote code execution.

Patches

https://github.com/flipped-aurora/gin-vue-admin/pull/1264

Workarounds

https://github.com/flipped-aurora/gin-vue-admin/pull/1264

References

1263

For more information

The plugin installation function of Gin-Vue-Admin allows users to download zip packages from the plugin market and upload them for installation. This function has an arbitrary file upload vulnerability. A malicious attacker can upload a constructed zip package to traverse the directory and upload or overwrite arbitrary files on the server side.

The affected code https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/service/system/sys_auto_code.go line 880 called the utils.Unzip method

paths, err := utils.Unzip(GVAPLUGPINATH+file.Filename, GVAPLUGPINATH)
    paths = filterFile(paths)
    var webIndex = -1
    var serverIndex = -1
    for i := range paths {
        paths[i] = filepath.ToSlash(paths[i])
        pathArr := strings.Split(paths[i], "/")
        ln := len(pathArr)
        if ln < 2 {
            continue
        }
        if pathArr[ln-2] == "server" && pathArr[ln-1] == "plugin" {
            serverIndex = i
        }
        if pathArr[ln-2] == "web" && pathArr[ln-1] == "plugin" {
            webIndex = i
        }
    }
    if webIndex == -1 && serverIndex == -1 {
        zap.L().Error("非标准插件,请按照文档自动迁移使用")
        return webIndex, serverIndex, errors.New("非标准插件,请按照文档自动迁移使用")
    }
...

The https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/utils/zip.go code defines the utils.Unzip method

//解压
func Unzip(zipFile string, destDir string) ([]string, error) {
    zipReader, err := zip.OpenReader(zipFile)
    var paths []string
    if err != nil {
        return []string{}, err
    }
    defer zipReader.Close()

    for _, f := range zipReader.File {
        fpath := filepath.Join(destDir, f.Name)
        paths = append(paths, fpath)
        if f.FileInfo().IsDir() {
            os.MkdirAll(fpath, os.ModePerm)
...

It can be analyzed that after uploading a zip compressed file, the Unzip method will be called to decompress the compressed file, and then judge whether the compressed file contains the fixed directory structure of server, web, and plugin.

Whether the zip file is correct or not, it will be decompressed first. If the directory does not exist, it will be created automatically. Therefore, malicious zip packages can be constructed, and directory traversal can be performed during automatic decompression to upload or overwrite any file.

Use the Zip Slip vulnerability to construct a malicious zip package with ../../../../ filenames, and upload the malicious zip package to trigger the vulnerability.

1 2

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/flipped-aurora/gin-vue-admin/server"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "2.5.4"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2022-39345"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-22"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2022-10-25T21:02:23Z",
    "nvd_published_at": "2022-10-25T17:15:00Z",
    "severity": "CRITICAL"
  },
  "details": "### Impact\nGin-vue-admin \u003c 2.5.4 has File upload vulnerabilities\u3002\nFile upload vulnerabilities are when a web server allows users to upload files to its filesystem without sufficiently validating things like their name, type, contents, or size. Failing to properly enforce restrictions on these could mean that even a basic image upload function can be used to upload arbitrary and potentially dangerous files instead. This could even include server-side script files that enable remote code execution.\n\n### Patches\n\nhttps://github.com/flipped-aurora/gin-vue-admin/pull/1264\n\n### Workarounds\n\nhttps://github.com/flipped-aurora/gin-vue-admin/pull/1264\n### References\n\n#1263 \n\n### For more information\nThe plugin installation function of Gin-Vue-Admin allows users to download zip packages from the plugin market and upload them for installation. This function has an arbitrary file upload vulnerability. A malicious attacker can upload a constructed zip package to traverse the directory and upload or overwrite arbitrary files on the server side.\n\nThe affected code https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/service/system/sys_auto_code.go line 880 called the `utils.Unzip` method\n\n```\npaths, err := utils.Unzip(GVAPLUGPINATH+file.Filename, GVAPLUGPINATH)\n\tpaths = filterFile(paths)\n\tvar webIndex = -1\n\tvar serverIndex = -1\n\tfor i := range paths {\n\t\tpaths[i] = filepath.ToSlash(paths[i])\n\t\tpathArr := strings.Split(paths[i], \"/\")\n\t\tln := len(pathArr)\n\t\tif ln \u003c 2 {\n\t\t\tcontinue\n\t\t}\n\t\tif pathArr[ln-2] == \"server\" \u0026\u0026 pathArr[ln-1] == \"plugin\" {\n\t\t\tserverIndex = i\n\t\t}\n\t\tif pathArr[ln-2] == \"web\" \u0026\u0026 pathArr[ln-1] == \"plugin\" {\n\t\t\twebIndex = i\n\t\t}\n\t}\n\tif webIndex == -1 \u0026\u0026 serverIndex == -1 {\n\t\tzap.L().Error(\"\u975e\u6807\u51c6\u63d2\u4ef6\uff0c\u8bf7\u6309\u7167\u6587\u6863\u81ea\u52a8\u8fc1\u79fb\u4f7f\u7528\")\n\t\treturn webIndex, serverIndex, errors.New(\"\u975e\u6807\u51c6\u63d2\u4ef6\uff0c\u8bf7\u6309\u7167\u6587\u6863\u81ea\u52a8\u8fc1\u79fb\u4f7f\u7528\")\n\t}\n...\n```\nThe https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/utils/zip.go code defines the `utils.Unzip` method\n```\n//\u89e3\u538b\nfunc Unzip(zipFile string, destDir string) ([]string, error) {\n\tzipReader, err := zip.OpenReader(zipFile)\n\tvar paths []string\n\tif err != nil {\n\t\treturn []string{}, err\n\t}\n\tdefer zipReader.Close()\n\n\tfor _, f := range zipReader.File {\n\t\tfpath := filepath.Join(destDir, f.Name)\n\t\tpaths = append(paths, fpath)\n\t\tif f.FileInfo().IsDir() {\n\t\t\tos.MkdirAll(fpath, os.ModePerm)\n...\n```\nIt can be analyzed that after uploading a zip compressed file, the `Unzip` method will be called to decompress the compressed file, and then judge whether the compressed file contains the fixed directory structure of server, web, and plugin.\n\nWhether the zip file is correct or not, it will be decompressed first. If the directory does not exist, it will be created automatically. Therefore, malicious zip packages can be constructed, and directory traversal can be performed during automatic decompression to upload or overwrite any file.\n\nUse the Zip Slip vulnerability to construct a malicious zip package with `../../../../` filenames, and upload the malicious zip package to trigger the vulnerability.\n\n![1](https://user-images.githubusercontent.com/113822259/197387942-e40c188d-cff0-4da3-84ba-7ca670d9bf72.png)\n![2](https://user-images.githubusercontent.com/113822259/197387956-cef8fd0d-978a-47ae-a65e-e28367f6a0b8.png)\n",
  "id": "GHSA-7gc4-r5jr-9hxv",
  "modified": "2022-10-27T18:38:32Z",
  "published": "2022-10-25T21:02:23Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/flipped-aurora/gin-vue-admin/security/advisories/GHSA-7gc4-r5jr-9hxv"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2022-39345"
    },
    {
      "type": "WEB",
      "url": "https://github.com/flipped-aurora/gin-vue-admin/issues/1263"
    },
    {
      "type": "WEB",
      "url": "https://github.com/flipped-aurora/gin-vue-admin/pull/1264"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/flipped-aurora/gin-vue-admin"
    },
    {
      "type": "WEB",
      "url": "https://github.com/flipped-aurora/gin-vue-admin/blob/main/server/service/system/sys_auto_code.go"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Gin-vue-admin subject to Remote Code Execution via file upload vulnerability"
}



Log in or create an account to share your comment.




Tags
Taxonomy of the tags.


Loading…

Loading…

Loading…

Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.

Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.

Sightings

Author Source Type Date Other

Nomenclature

  • Seen: The vulnerability was mentioned, discussed, or observed by the user.
  • Confirmed: The vulnerability has been validated from an analyst's perspective.
  • Published Proof of Concept: A public proof of concept is available for this vulnerability.
  • Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
  • Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
  • Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
  • Not confirmed: The user expressed doubt about the validity of the vulnerability.
  • Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline

Sightings and recorded dates, grouped by day · UTC

JSON
How durations are calculated

Following the VTEM framework (Black Hat USA 2015), time to patch starts when the vendor or a coordinator was informed, total time to patch at discovery, and disclosure to patch at public disclosure; vendor response time runs from the report to its acknowledgement. Time to exploit and time unpatched start at the earliest discovery or report, falling back to public disclosure. Unpatched time ends at the first recorded patch, or the calculation time when no patch is recorded. Exploitation to patch shows the interval between those two events; a published proof of concept is a public exploit, not exploitation. The method is described in a publication.

Each result shows its source dates. A negative interval means the end event came first; when date-only inputs leave the order open, the result says so. Date-only inputs are approximate. The earliest evidence wins: KEV report dates and sightings are labelled as such. Records describing another vulnerability are listed but never calculated from, and a PoC alone does not establish exploitation. Missing patch evidence does not prove that no patch exists. Filters below change the event list only.

Events included in the timeline

Loading timeline…


    Loading…

    Loading…

    Loading…

    Related by attack behaviour

    Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.