The vulnerability is an unauthenticated remote code execution in Langflow. It exists because the /api/v1/build_public_tmp/{flow_id}/flow endpoint, which is designed to be unauthenticated for public flows, incorrectly accepts an optional data parameter. This parameter allows an attacker to supply their own flow definition, which can contain arbitrary Python code. This code is then executed by the server without any sandboxing.
The execution chain starts at the build_public_tmp function in src/backend/base/langflow/api/v1/chat.py. This function takes the attacker-controlled data and passes it to start_flow_build. The data then flows through a series of functions that build a graph from the provided flow definition. Ultimately, the prepare_global_scope function in src/lfx/src/lfx/custom/validate.py is called, which uses exec() to execute the malicious code.
The root cause of the vulnerability is the combination of a lack of authentication on a critical endpoint and the improper handling of user-supplied data, which is treated as trusted code. The recommended fix is to remove the data parameter from the build_public_tmp function, forcing public flows to only use their stored data.