Listen to this Post
The vulnerability exists in the `/api/v1/flows/` POST endpoint. An authenticated client can include an `fs_path` field in the request body. The `_verify_fs_path()` function receives this user-controlled string, converts it to a Path object, and creates the file if it doesn’t exist, without any validation. Subsequently, `_save_flow_to_fs()` serializes the Flow object to JSON and writes it to the provided `fs_path` in overwrite mode (“w”). There are no checks for path traversal sequences (../), normalization to a safe root directory, or restrictions on absolute paths. This allows an attacker to specify paths like `/etc/poc.txt` or ../../critical.conf. The server process writes the JSON data to the specified location, leading to arbitrary file creation or overwrite within the bounds of the server’s filesystem permissions.
Platform: Langflow
Version: ac6e2d2eabeee28085f2739d79f7ce4205ca082c
Vulnerability : Arbitrary File Write
Severity: Critical
date: 2024-12-21
Prediction: 2025-01-15
What Undercode Say:
curl -sS -X POST "http://localhost:7860/api/v1/flows/" \
-H "Content-Type: application/json" \
-H "x-api-key: sk-8Kyzf9IQ-UEJ_OtSTaJq4eniMT9_JKgZ7__q8PNkoxc" \
-d '{"name":"poc-etc","data":{"nodes":[],"edges":[]},"fs_path":"/tmp/POC.txt"}'
How Exploit:
Authenticated user sends POST request with malicious `fs_path`.
Protection from this CVE:
Enforce save root.
Normalize all paths.
Block symlink traversal.
Minimize server permissions.
Impact:
Authenticated arbitrary file write.
System file corruption risk.
JSON content overwrite.
🎯Let’s Practice Exploiting & Learn Patching For Free:
Sources:
Reported By: github.com
Extra Source Hub:
Undercode

