Summary
Langflow's public flow builder API endpoint /api/v1/build_public_tmp/{flow_id}/flow can accept attacker-supplied flow data that contains arbitrary Python code, which is executed via exec() with no sandboxing.
Because this endpoint is intentionally exposed without authentication for public flows, an attacker can remotely trigger code execution on the Langflow server without any valid credentials.
Affected context
This vulnerability affects Langflow deployments that expose the /api/v1/build_public_tmp/{flow_id}/flow endpoint for building public flows.
The issue is present when:
- The endpoint is accessible over a network (e.g., internet-exposed or reachable within an internal network), and
- The server accepts the optional
dataparameter in POST requests and treats it as flow definition input, and - Flow node definitions can embed Python code that is passed directly to a Python
exec()call.
In such configurations, the API does not require authentication and does not restrict or sandbox the executable code extracted from the supplied flow data.
Exploit preconditions
- Attack surface: HTTP POST requests to
/api/v1/build_public_tmp/{flow_id}/flow. - Required access: Network access to the Langflow instance; no authentication or valid user account is required.
- Input control: Ability to send a crafted
dataparameter whose contents define nodes containing arbitrary Python code. - Trigger point: The server processes the incoming flow data and passes the embedded Python code directly to
exec()during flow build for the givenflow_id. - Why exploitation is possible: The endpoint:
- Is intentionally unauthenticated for public flows (CWE-306: Missing Authentication for Critical Function),
- Trusts attacker-supplied
dataover stored, validated flow definitions, - Passes node-defined code directly into
exec()without sandboxing or validation (CWE-94/CWE-95), - Executes this logic in the server environment, inheriting its privileges.
Why this happens
The root cause is the combination of missing authentication on a security-sensitive API and unsafe dynamic code execution.
The /api/v1/build_public_tmp/{flow_id}/flow endpoint is designed to allow building "public" flows, so it omits authentication checks (CWE-306).
However, it also accepts an optional data parameter that can replace the stored flow data with attacker-controlled content.
Flow node definitions within this data can include Python code that is passed directly into exec() without sandboxing, validation, or restriction.
This pattern maps to CWE-94: Improper Control of Generation of Code and CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code, where user input directly influences executable code.
Because the code runs with the server's Python interpreter, an attacker can execute arbitrary commands in the context of the Langflow process.
Potential impact
- Unauthenticated execution of arbitrary Python code on the Langflow server.
- Reading, modifying, or deleting application data accessible to the Langflow process.
- Pivoting into the underlying host or container environment, including executing OS-level commands via Python libraries.
- Exfiltration of sensitive configuration, environment variables, or credentials used by Langflow.
- Disruption of AI workflows, manipulation of flows, or deployment of backdoored agents and components.
- Use of the compromised Langflow instance as a foothold for lateral movement within the hosting infrastructure.
General mitigation guidance
Mitigation strategies focus on removing direct code execution from untrusted inputs and enforcing appropriate access control around flow-building operations:
- Avoid passing any user-controllable data directly into
exec(),eval(), or equivalent dynamic evaluation mechanisms; use explicit, declarative configuration formats instead of executable code in flow definitions. - Introduce strict authentication and authorization requirements for endpoints that can trigger code execution or flow building, even for "public" resources, or separate read-only public endpoints from code-executing ones.
- If dynamic code is unavoidable, implement strong sandboxing and isolation for code execution:
- Run untrusted code in constrained, separate processes or containers with minimal privileges and limited filesystem/network access.
- Validate and normalize flow definitions before processing:
- Reject nodes or fields that contain raw code where only configuration should be present.
- Enforce schema-based validation and maintain a clear separation between data and executable logic.
- Apply least-privilege principles for the Langflow runtime:
- Limit filesystem, network, and credential access available to the process executing flows, so that any compromise has reduced blast radius.
How teams detect issues like this
Detection can leverage both code-level analysis and operational monitoring:
- Static analysis and code review:
- Search for uses of
exec(),eval(), or dynamic import mechanisms that are reachable from HTTP handlers or other untrusted input sources. - Flag code paths where request parameters (such as
data) are used to construct or influence executable Python code. - Review unauthenticated or "public" endpoints that trigger build, deploy, or validation actions for potential privilege mismatches.
- Security testing and fuzzing:
- Perform API-focused security tests that send crafted flow definitions with embedded code to endpoints that build or validate flows.
- Verify that public endpoints cannot alter runtime behavior through arbitrary code.
- Runtime and log monitoring:
- Monitor process behavior for unexpected command execution, new subprocess creation, or abnormal file/network access initiated from flow builds.
- Enable detailed logging for build-related endpoints to detect suspicious
datapayloads or anomalous flows being built. - Automated pipeline checks:
- Integrate SAST/IAST tools into CI to detect dynamic code execution patterns tied to web or API inputs.
- Enforce policy checks that forbid merging changes introducing unauthenticated code-execution paths.

