# CVE-2024-31457: gin-vue-admin background arbitrary code coverage vulnerability

> Attackers can inject arbitrary Go code via directory traversal in the plugin system, leading to remote code execution.

- **Severity:** High 7.7 (`CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:N/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 9 Apr 2024
- **Updated:** 2 Aug 2024
- **Also known as:** GHSA-gv3w-m57p-3wc4, GO-2024-2702

## What is CVE-2024-31457?

CVE-2024-31457 is a high-severity code injection vulnerability in flipped-aurora gin-vue-admin, published on 9 Apr 2024. An attacker needs administrator access to exploit it, with no action from the victim.

### Official description

gin-vue-admin is a backstage management system based on vue and gin, which separates the front and rear of the full stack. gin-vue-admin pseudoversion 0.0.0-20240407133540-7bc7c3051067, corresponding to version 2.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. The main reason for the existence of this vulnerability is the controllability of the PlugName field within the struct. Pseudoversion 0.0.0-20240409100909-b1b7427c6ea6, corresponding to commit b1b7427c6ea6c7a027fa188c6be557f3795e732b, contains a patch for the issue. As a workaround, one may manually use a filtering method available in the GitHub Security Advisory to rectify the directory traversal problem.

Weakness: CWE-22 (Improper Limitation of a Pathname to a Restricted Directory)

## Which versions are affected by CVE-2024-31457?

3 open source packages ship an affected version, including github.com/flipped-aurora/gin-vue-admin/server.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/flipped-aurora/gin-vue-admin/server` | Go | All versions | 0.0.0-20240409100909-b1b7427c6ea6 |
| `github.com/flipped-aurora/gin-vue-admin/server` | Go | All versions | 0.0.0-20240409100909-b1b7427c6ea6 |
| `github.com/flipped-aurora/gin-vue-admin/server` | Go | All versions | 0.0.0-20240409100909-b1b7427c6ea6 |

## How do I fix CVE-2024-31457?

Upgrade github.com/flipped-aurora/gin-vue-admin/server to 0.0.0-20240409100909-b1b7427c6ea6 or later.

## Is CVE-2024-31457 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-31457 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-31457 and fix it if it is affected.

What it is: CVE-2024-31457 is a high-severity code injection vulnerability in flipped-aurora gin-vue-admin, published on 9 Apr 2024. An attacker needs administrator access to exploit it, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-31457 exists.

Affected packages and fixed versions:
- github.com/flipped-aurora/gin-vue-admin/server (Go): affected all versions; fixed in 0.0.0-20240409100909-b1b7427c6ea6
- github.com/flipped-aurora/gin-vue-admin/server (Go): affected all versions; fixed in 0.0.0-20240409100909-b1b7427c6ea6
- github.com/flipped-aurora/gin-vue-admin/server (Go): affected all versions; fixed in 0.0.0-20240409100909-b1b7427c6ea6

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-31457/ (Markdown: https://insights.sbomify.com/CVE-2024-31457/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-31457
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-31457
- OSV: https://osv.dev/vulnerability/CVE-2024-31457

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-31457/
Summaries are generated and may contain mistakes; the official description above is the record.
