/

CVE-2026-33873

Severity:

CRITICAL RISK

(9.9)

Code Injection in Langflow Agentic Assistant

CVE-2026-33873

Analyzed

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution on the Langflow Server

Severity:

CRITICAL RISK

(9.9)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

The Agentic Assistant feature in Langflow executes LLM-generated Python code during a validation phase, but this phase reaches dynamic execution sinks and instantiates the generated classes on the server.

If an attacker can access the Agentic Assistant and steer or control the model's output, they can cause arbitrary Python code to run on the server hosting Langflow.

Affected context

This vulnerability impacts Langflow deployments that expose the Agentic Assistant feature to users or external systems.

It is especially relevant where:

  • The LLM can be influenced by user prompts or upstream data,
  • LLM-generated Python components are automatically validated and instantiated server-side, and
  • Generated code is executed in the same trust boundary and permissions as the Langflow backend.

In such settings, the validation step is not purely static; it leads to dynamic code execution of model-produced Python.

Exploit preconditions

  • Attack surface: Langflow Agentic Assistant interface (UI, API, or any workflow that triggers the Assistant to generate Python components).
  • Required access: Ability to interact with the Agentic Assistant and influence the LLM's output (e.g., by prompting, providing training-like content, or manipulating upstream data consumed by the model).
  • Trigger point: Initiation of the component validation or generation flow where Langflow takes the LLM-generated Python code, reaches dynamic execution sinks, and instantiates the resulting class.
  • Why exploitation is possible: The design assumes that LLM-generated code used for component validation is safe and trustworthy. Instead of performing static checks, the validation phase actually executes the generated Python in-process on the server, creating a direct path from model output to code execution (CWE-94).

Why this happens

The root cause is the insecure pattern of treating generated Python code as trusted logic and feeding it directly into dynamic execution mechanisms during a "validation" phase.

Rather than limiting the process to static inspection, sandboxed analysis, or constrained evaluation, the Agentic Assistant:

  • Accepts arbitrary Python emitted by an LLM,
  • Passes this code to dynamic execution sinks (e.g., constructs that evaluate or import code at runtime),
  • Instantiates the produced class in the same runtime context as the application server.

This aligns with CWE-94: Improper Control of Generation of Code, where external input (here, model output driven by user influence) can change what code is generated and executed, without strict validation, isolation, or policy enforcement.

The validation step is effectively a misnamed execution step, collapsing the trust boundary between untrusted model output and privileged server-side code execution.

Potential impact

  • Arbitrary Python code execution on the Langflow server.
  • Reading or modification of backend application data accessible to the Langflow process.
  • Lateral movement within the hosting environment, depending on available credentials and network access.
  • Deployment of backdoors or persistent malicious components inside Langflow workflows.
  • Interference with or manipulation of AI workflows, leading to data exfiltration, integrity loss, or model abuse.
  • Use of the compromised Langflow instance as a pivot for broader infrastructure attacks.

General mitigation guidance

Effective mitigation centers on breaking the direct path from untrusted model output to executable code and enforcing strict boundaries around dynamic behaviors.

Common defensive patterns include:

  • Eliminate direct execution of generated code: Avoid using eval, dynamic imports, or runtime compilation on any code that originates from or is influenced by an LLM or user-controlled sources.
  • Treat LLM output as untrusted input: Apply the same safeguards as you would for user-submitted scripts, including validation, sanitization, and policy controls before any code is accepted.
  • Use constrained execution environments: If executing generated code is unavoidable, run it only within hardened sandboxes or isolated runtimes (e.g., separate containers, restricted interpreters, or jailed environments) with:
  • Strong OS-level isolation,
  • No access to secrets or production data,
  • Minimal filesystem and network permissions.
  • Restrict capabilities and permissions: Run the Langflow backend and any auxiliary execution environments with least-privilege, avoiding unnecessary system-level permissions or broad network access.
  • Enforce allowlists of APIs and patterns: Limit which modules, functions, and side effects can be used by any generated components by enforcing strict allowlists and rejecting code violating these policies.
  • Introduce non-executable validation: Implement static or semantic checks that do not require executing the generated code (e.g., AST inspection, pattern matching, or schema-based component definitions) to validate structure and intent.
  • Harden AI-assisted features by design: Architect the Agentic Assistant and similar systems so that model output describes configurations or plans, not raw code, and translate those descriptions into vetted, pre-defined building blocks.

How teams detect issues like this

Organizations can approach detection by focusing on how and where dynamic execution is used in conjunction with LLM outputs.

Potential strategies:

  • Static analysis:
  • Search for dynamic execution sinks (e.g., generic eval-like functions, dynamic imports, runtime compilation) in code paths reachable from LLM or user-controlled input.
  • Flag patterns where model outputs or prompt-derived strings feed directly into code-generation or execution utilities.
  • Code review focus areas:
  • Examine AI-assisted features, "Agentic" or "Assistant" components, and any "validation" or "generation" stages for hidden dynamic execution.
  • Look for misnamed validation steps that actually instantiate or invoke generated classes or functions.
  • Review use of reflection or metaprogramming mechanisms that act on content derived from LLM responses.
  • Runtime monitoring and policy enforcement:
  • Implement application-level guards that block or log attempts to execute dynamically generated code when it originates from model outputs.
  • Monitor for unexpected module imports, file operations, or outbound network calls originating from AI agent execution paths.
  • Use of automated tools:
  • Employ SAST or semantic code-scanning tools configured to detect CWE-94 patterns, especially in code that processes LLM responses.
  • Incorporate these checks into CI/CD pipelines for all changes affecting AI-agent components or dynamic plugin systems.

Sources

SourceLink
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/agentic/api/router.py#L252-L297
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/agentic/api/schemas.py#L20-L31
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/agentic/helpers/code_extraction.py#L11-L53
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/agentic/helpers/validation.py#L27-L47
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/agentic/services/assistant_service.py#L142-L156
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/agentic/services/assistant_service.py#L259-L300
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/agentic/services/assistant_service.py#L58-L79
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/api/utils/core.py#L38
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/api/v1/login.py#L96-L135
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/services/auth/utils.py#L156-L163
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/backend/base/langflow/services/auth/utils.py#L39-L53
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/lfx/src/lfx/custom/validate.py#L241-L272
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/lfx/src/lfx/custom/validate.py#L394-L399
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/lfx/src/lfx/custom/validate.py#L441-L443
github.comgithub.com/langflow-ai/langflow/blob/f7f4d1e70ba5eecd18162ec96f3571c2cfbcd1fc/src/lfx/src/lfx/services/settings/auth.py#L71-L87
github.comgithub.com/langflow-ai/langflow/security/advisories/GHSA-v8hw-mh8c-jxfc

Frequently asked

questions

It can be, if the Agentic Assistant is exposed through a web UI or API where remote users or integrated systems can influence the prompts or other inputs that drive the LLM's output. In such cases, an attacker may be able to trigger code execution without direct system-level access, purely through crafted interactions with the Assistant.

The attacker needs the ability to interact with the Agentic Assistant feature in a way that meaningfully steers the LLM's responses—for example, submitting prompts, providing contextual data, or controlling upstream sources the model consumes. Direct shell or file-system access is not required if the Assistant is reachable over the network.

The safest pattern is to prevent LLM-generated content from being executed as code at all. Instead, restrict AI output to declarative specifications (e.g., configuration objects, flow descriptions) and map those specifications onto pre-defined, vetted implementation components. Where code generation is necessary, keep it as an offline development aid with human review, not an automatic runtime execution path.

Treat AI and LLM outputs as untrusted, user-controlled input by default. Design systems so that:

  • Model outputs cannot directly reach dynamic execution sinks,
  • Any required execution happens in strictly isolated and least-privilege environments,
  • Validation steps are non-executable and policy-driven,
  • Security reviews and automated analysis specifically target AI integration points for CWE-94 and related code injection patterns.
Find out what's already
exploitable in your codebase.