CVE-2022-39345: Github.com/flipped aurora/gin vue admin/server Remote Code Execution Vulnerability
CRITICALCVE-2022-39345 is a CRITICAL (CVSS 9.8) remote code execution vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Github.com/flipped aurora/gin vue admin/server libraries in the Go ecosystem. The issue involves gin-vue-admin subject to remote code execution via file upload vulnerability. Remediation is available by upgrading affected packages to version 2.5.4.
CVE-2022-39345 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2022-39345
To remediate this vulnerability, upgrade all affected Github.com/flipped aurora/gin vue admin/server dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade github.com/flipped-aurora/gin-vue-admin/server to 2.5.4
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for github.com/flipped-aurora/gin-vue-admin/server
How to Check if You Are Affected
To determine whether your application is affected by CVE-2022-39345, inspect your project dependencies for Github.com/flipped aurora/gin vue admin/server:
inspect dependencies for github.com/flipped-aurora/gin-vue-admin/server
Analyze the terminal output to locate any version of Github.com/flipped aurora/gin vue admin/server in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.5.4), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Github.com/flipped aurora/gin vue admin/server, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2022-39345 Affected Github.com/flipped aurora/gin vue admin/server Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
github.com/flipped-aurora/gin-vue-admin/server
|
Go |
< 2.5.4
|
2.5.4
|
References
Frequently Asked Questions
What is CVE-2022-39345?
Which Github.com/flipped aurora/gin vue admin/server versions are affected?
What version fixes CVE-2022-39345?
Is github.com/flipped-aurora/gin-vue-admin/server affected?
What is the CVSS score of CVE-2022-39345?
What CWE is associated with CVE-2022-39345?
How can I check Go dependencies for CVE-2022-39345?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-7gc4-r5jr-9hxv",
"modified" : "2022-10-27T18:38:32Z",
"published" : "2022-10-25T21:02:23Z",
"aliases" : [ "CVE-2022-39345" ],
"summary" : "Gin-vue-admin subject to Remote Code Execution via file upload vulnerability",
"details" : "### Impact\nGin-vue-admin < 2.5.4 has File upload vulnerabilities。\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 < 2 {\n\t\t\tcontinue\n\t\t}\n\t\tif pathArr[ln-2] == \"server\" && pathArr[ln-1] == \"plugin\" {\n\t\t\tserverIndex = i\n\t\t}\n\t\tif pathArr[ln-2] == \"web\" && pathArr[ln-1] == \"plugin\" {\n\t\t\twebIndex = i\n\t\t}\n\t}\n\tif webIndex == -1 && serverIndex == -1 {\n\t\tzap.L().Error(\"非标准插件,请按照文档自动迁移使用\")\n\t\treturn webIndex, serverIndex, errors.New(\"非标准插件,请按照文档自动迁移使用\")\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//解压\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\n\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Go",
"name" : "github.com/flipped-aurora/gin-vue-admin/server"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.5.4"
} ]
} ]
} ],
"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"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-22" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2022-10-25T21:02:23Z",
"nvd_published_at" : "2022-10-25T17:15:00Z"
}
}