VAITP Dataset

← Back to the dataset

CVE-2026-0769

Langflow's eval_custom_component_code is vulnerable to unauthenticated RCE.

  • CVSS 9.8
  • CWE-95
  • Input Validation and Sanitization
  • Remote

Langflow eval_custom_component_code Eval Injection Remote Code Execution Vulnerability. This vulnerability allows remote attackers to execute arbitrary code on affected installations of Langflow. Authentication is not required to exploit this vulnerability. The specific flaw exists within the implementation of eval_custom_component_code function. The issue results from the lack of proper validation of a user-supplied string before using it to execute python code. An attacker can leverage this vulnerability to execute code in the context of the current process. Was ZDI-CAN-26972.

CVSS base score
9.8
Published
2026-01-23
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Langflow
Fixed by upgrading
Yes

Solution

Upgrade to Langflow version 1.0.0a27 or later.

Vulnerable code sample

import collections.abc

class LangflowComponent:
    def eval_custom_component_code(self, user_data: dict):
        """
        Evaluates the code for a custom component provided by the user.
        The user_data dictionary is expected to contain a 'code' key
        with a string of Python code to be executed.
        """
        if "code" in user_data:
            code_string = user_data["code"]
            try:
                # The vulnerability is the direct evaluation of the user-supplied string.
                # No validation or sandboxing is performed.
                result = eval(code_string, {"__builtins__": __builtins__})
                return {"status": "success", "return_value": repr(result)}
            except Exception as e:
                return {"status": "error", "message": str(e)}
        return {"status": "error", "message": "No code provided."}

Patched code sample

import ast
from typing import Any, Dict


def eval_custom_component_code(code: str) -> Dict[str, Any]:
    """
    Evaluates the given Python code and returns the global variables
    after execution.

    This function now includes security measures to prevent arbitrary code execution
    by parsing the code into an Abstract Syntax Tree (AST) and checking for
    disallowed operations like imports or dangerous function calls.

    Args:
        code (str): The Python code to evaluate.

    Returns:
        Dict[str, Any]: A dictionary of global variables after the code has
                        been executed.

    Raises:
        ValueError: If the code contains disallowed operations.
    """
    # Disallowed keywords - we don't want to allow imports
    disallowed_keywords = ["import"]
    # Disallowed nodes - we don't want to allow imports, and we want to prevent
    # any calls to functions that could be used for remote code execution.
    disallowed_nodes = [
        ast.Import,
        ast.ImportFrom,
    ]
    # We also want to prevent calls to open, eval, exec
    # and any dunder methods.
    disallowed_function_calls = ["open", "eval", "exec"]

    # Check for disallowed keywords
    if any(keyword in code for keyword in disallowed_keywords):
        raise ValueError("Code contains disallowed keywords.")

    # Parse the code into an AST
    try:
        tree = ast.parse(code)
    except SyntaxError as e:
        raise ValueError(f"Invalid Python code: {e}") from e

    # Check for disallowed nodes in the AST
    for node in ast.walk(tree):
        if any(isinstance(node, disallowed_node) for disallowed_node in disallowed_nodes):
            raise ValueError(f"Code contains disallowed AST nodes: {type(node).__name__}")
        # Check for disallowed function calls
        if isinstance(node, ast.Call) and isinstance(node.func, ast.Name):
            if node.func.id in disallowed_function_calls:
                raise ValueError(f"Code contains disallowed function call: {node.func.id}")
        # Check for dunder methods
        if isinstance(node, ast.Attribute) and node.attr.startswith("__") and node.attr.endswith("__"):
            raise ValueError(f"Code contains disallowed dunder method call: {node.attr}")

    # If the code is safe, execute it
    globals_dict: Dict[str, Any] = {}
    exec(code, globals_dict)

    return globals_dict

Payload

__import__('os').system('id')

Cite this entry

@misc{vaitp:cve20260769,
  title        = {{Langflow's eval_custom_component_code is vulnerable to unauthenticated RCE.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-0769},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-0769/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::