Summary
The Langflow CSV Agent node previously hardcoded allow_dangerous_code=True, implicitly exposing LangChain's Python REPL tool (python_repl_ast) to user-controlled prompts.
Under these conditions, an attacker can inject malicious instructions into prompts to execute arbitrary Python and OS commands on the Langflow server, resulting in full remote code execution (RCE).
Affected context
This vulnerability affects Langflow deployments that:
- Use the CSV Agent node in flows or agents
- Allow end users or external systems to provide prompt content, file data, or other untrusted text that the CSV Agent processes
- Run Langflow with network-accessible interfaces (e.g., SaaS-style, shared internal tools, or public demos)
The risk is most pronounced where users can supply arbitrary questions or instructions to the CSV Agent and where the Langflow process runs with substantial system or network privileges.
Exploit preconditions
- Attack surface: Application-layer prompts sent to the Langflow CSV Agent node (e.g., chat UIs, APIs, or workflow inputs).
- Required access: Ability to submit or influence prompts processed by the CSV Agent; this may be anonymous or low-privilege depending on deployment configuration.
- Trigger point: The CSV Agent, configured with
allow_dangerous_code=True, routes instructions to LangChain'spython_repl_asttool when prompted by the model. - Why exploitation is possible: The system exposes a general-purpose Python REPL tool by default and allows LLM-driven tool selection based on prompt content. An attacker can craft prompt injection payloads that cause the model to call the REPL with attacker-controlled code, leading to arbitrary command execution on the host.
Why this happens
The root cause is the unsafe exposure of a powerful code execution primitive (LangChain's python_repl_ast tool) as a default capability of the CSV Agent. By hardcoding allow_dangerous_code=True, the component effectively treats natural-language prompts—often originating from untrusted users—as authorization to execute arbitrary Python code.
This maps to CWE-94: Improper Control of Generation of Code ('Code Injection'). Instead of enforcing strict boundaries between user input, model reasoning, and executable code, the design permits user-influenced prompts to drive direct invocation of a Python REPL. No robust policy, sandboxing, or explicit opt-in gating checks are enforced, allowing attacker-controlled content to flow into a code execution environment.
Potential impact
- Arbitrary Python code execution on the Langflow server
- Execution of OS commands with the privileges of the Langflow process
- Reading, modifying, or deleting local files accessible to the service
- Accessing environment variables, credentials, and API keys
- Pivoting to other internal services or databases reachable from the server
- Exfiltration or corruption of sensitive data processed by Langflow workflows
- Full compromise of the Langflow host and potential lateral movement within the network
General mitigation guidance
Effective mitigation focuses on removing default access to dangerous execution tools and treating all LLM-driven code execution as highly privileged:
- Disable or strictly gate any general-purpose code execution tools (e.g., Python REPL, shell execution) in agent/tool configurations, especially in nodes exposed to untrusted prompts.
- Introduce explicit configuration flags that default to safe settings (e.g.,
allow_dangerous_code=False) and require deliberate opt-in for high-risk capabilities. - Apply strong separation of concerns between user prompts, model reasoning, and executable actions; avoid direct flows where model output becomes code without additional validation or approval.
- Run LLM-powered components under least-privilege OS accounts, with restricted filesystem and network access, and avoid colocating them with sensitive services.
- When code execution is truly required, consider sandboxing strategies (containers, micro-VMs, or restricted interpreters) to isolate the blast radius of potential compromise.
- Document and communicate the security implications of enabling dangerous tools so operators can make informed deployment decisions.
How teams detect issues like this
Organizations can identify and monitor for similar vulnerabilities using a combination of code-based and runtime strategies:
- Static analysis and configuration review:
- Search for use of interpreter/REPL tools (e.g.,
python_repl_ast, generic Python REPLs) wired into LLM agents, especially when tied to flags likeallow_dangerous_codeor similar. - Flag configurations where high-risk tools are enabled by default or controlled through hardcoded values rather than secure configuration options.
- Add code review checklists that explicitly ask whether LLM tools can cause code or command execution and how they are gated.
- Policy and CI enforcement:
- Implement repository or CI policies that block merging changes introducing new general-purpose code execution tools without additional safeguards.
- Use automated security scanning tools that can detect patterns of LLM output being passed into interpreters or shell commands.
- Runtime monitoring:
- Monitor process behavior for unexpected Python subprocesses, shell invocations, or spikes in REPL-like activity originating from LLM workflows.
- Collect and inspect audit logs of tool invocations by agents, focusing on tools capable of executing code or system commands.

