/

CVE-2026-51886

Severity:

CRITICAL RISK

(9.8)

Code Injection (CWE-94) in Langflow Validation Route

CVE-2026-51886

Awaiting Analysis

Vulnerability type

Category:

Code Injection

CWE:

CWE-94

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

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

A code injection vulnerability in Langflow's code validation API allows submitted Python source to reach a server-side compile and execution path without effective sandboxing. An authenticated attacker who can access the endpoint may execute arbitrary code on the Langflow server.

A code injection vulnerability in Langflow's code validation API allows submitted Python source to reach a server-side compile and execution path without effective sandboxing. An authenticated attacker who can access the endpoint may execute arbitrary code on the Langflow server.

Affected context

The issue occurs in Langflow deployments that expose the /api/v1/validate/code HTTP endpoint and process user-provided Python source through the validation functionality. Risk depends on the endpoint being reachable by an authenticated principal whose permissions are sufficient to submit validation requests, together with the service's ability to execute the supplied code within its server process.

The issue occurs in Langflow deployments that expose the /api/v1/validate/code HTTP endpoint and process user-provided Python source through the validation functionality. Risk depends on the endpoint being reachable by an authenticated principal whose permissions are sufficient to submit validation requests, together with the service's ability to execute the supplied code within its server process.

Exploit preconditions

  • Attack surface: HTTP or browser-backed Langflow service
  • Required access: Authenticated access capable of submitting requests to the code validation endpoint
  • Trigger point: A POST request to /api/v1/validate/code
  • Why exploitation is possible: User-controlled Python source is forwarded into a server-side compile/exec path without adequate sandboxing, authorization enforcement, or execution restrictions
  • Attack surface: HTTP or browser-backed Langflow service
  • Required access: Authenticated access capable of submitting requests to the code validation endpoint
  • Trigger point: A POST request to /api/v1/validate/code
  • Why exploitation is possible: User-controlled Python source is forwarded into a server-side compile/exec path without adequate sandboxing, authorization enforcement, or execution restrictions

Why this happens

The vulnerability results from treating user-supplied Python source as executable validation input rather than as untrusted data. A validation routine that compiles and executes submitted code without a strong isolation boundary creates a direct code injection condition, mapping to CWE-94: Improper Control of Generation of Code ('Code Injection'). Authentication alone does not provide a safe execution boundary when a user-controlled request can influence server-side interpreter behavior.

The vulnerability results from treating user-supplied Python source as executable validation input rather than as untrusted data. A validation routine that compiles and executes submitted code without a strong isolation boundary creates a direct code injection condition, mapping to CWE-94: Improper Control of Generation of Code ('Code Injection'). Authentication alone does not provide a safe execution boundary when a user-controlled request can influence server-side interpreter behavior.

Potential impact

  • An attacker may execute arbitrary Python or operating-system actions in the service process context.
  • The attacker could access application secrets, environment variables, or files available to the service account.
  • The vulnerability may enable unauthorized modification of workflows, data, or server-side configuration.
  • A compromised service could facilitate lateral movement or broader infrastructure compromise, depending on network and runtime privileges.
  • An attacker may execute arbitrary Python or operating-system actions in the service process context.
  • The attacker could access application secrets, environment variables, or files available to the service account.
  • The vulnerability may enable unauthorized modification of workflows, data, or server-side configuration.
  • A compromised service could facilitate lateral movement or broader infrastructure compromise, depending on network and runtime privileges.

General mitigation guidance

Mitigation generally focuses on removing server-side execution of untrusted source and reducing the trust placed in validation requests.

Common defensive patterns include:

  • Replace compile/exec-based validation with parsing, static inspection, or a narrowly defined declarative representation.
  • Enforce explicit authorization and entitlement checks at the endpoint and service layers.
  • If dynamic execution is unavoidable, isolate it in a strongly restricted, short-lived sandbox with minimal privileges, limited network access, resource quotas, and no sensitive credentials.
  • Apply strict request-size, syntax, and schema controls before processing input.
  • Run the application with a least-privilege service identity and segregate secrets from processes handling user-controlled code.
  • Treat authenticated users as untrusted for code execution purposes and apply audit logging and rate limits to validation operations.

Mitigation generally focuses on removing server-side execution of untrusted source and reducing the trust placed in validation requests.

Common defensive patterns include:

  • Replace compile/exec-based validation with parsing, static inspection, or a narrowly defined declarative representation.
  • Enforce explicit authorization and entitlement checks at the endpoint and service layers.
  • If dynamic execution is unavoidable, isolate it in a strongly restricted, short-lived sandbox with minimal privileges, limited network access, resource quotas, and no sensitive credentials.
  • Apply strict request-size, syntax, and schema controls before processing input.
  • Run the application with a least-privilege service identity and segregate secrets from processes handling user-controlled code.
  • Treat authenticated users as untrusted for code execution purposes and apply audit logging and rate limits to validation operations.

How teams detect issues like this

Organizations can look for:

  • Static analysis findings involving exec, eval, dynamic compilation, interpreter invocation, or equivalent execution APIs applied to request data.
  • Code review signals where HTTP request bodies flow into Python compilation or execution without a sandbox boundary.
  • Authorization reviews for validation or testing endpoints that accept source code.
  • Runtime monitoring for unusual child processes, filesystem access, outbound connections, or secret access originating from the Langflow service.
  • Policy enforcement that blocks dynamic code execution in request-handling paths and requires security review for exceptions.

Automated code-scanning and data-flow analysis tools may help identify user-controlled input reaching execution sinks.

Organizations can look for:

  • Static analysis findings involving exec, eval, dynamic compilation, interpreter invocation, or equivalent execution APIs applied to request data.
  • Code review signals where HTTP request bodies flow into Python compilation or execution without a sandbox boundary.
  • Authorization reviews for validation or testing endpoints that accept source code.
  • Runtime monitoring for unusual child processes, filesystem access, outbound connections, or secret access originating from the Langflow service.
  • Policy enforcement that blocks dynamic code execution in request-handling paths and requires security review for exceptions.

Automated code-scanning and data-flow analysis tools may help identify user-controlled input reaching execution sinks.

Sources

SourceLink
gist.github.comgist.github.com/Ro1ME/c11b1e63e4e8fca6b25275144f25ec2a
github.comgithub.com/langflow-ai/langflow/issues/13336

Frequently asked

questions

Yes, the affected attack surface is an HTTP API. Exploitation generally depends on an attacker having authenticated access that permits requests to the code validation endpoint.

The described path is authenticated, so an attacker would typically need valid credentials or another way to obtain an authorized session. The security boundary also depends on whether endpoint-level entitlement checks are correctly enforced.

Do not execute user-supplied Python during validation. Prefer parsing and static analysis, or use a rigorously isolated execution service with no access to application secrets or privileged resources.

Review all flows from HTTP input to dynamic execution sinks, enforce authorization at sensitive endpoints, apply least privilege, and use static analysis and runtime monitoring to detect unsafe code-execution paths.

Yes, the affected attack surface is an HTTP API. Exploitation generally depends on an attacker having authenticated access that permits requests to the code validation endpoint.

The described path is authenticated, so an attacker would typically need valid credentials or another way to obtain an authorized session. The security boundary also depends on whether endpoint-level entitlement checks are correctly enforced.

Do not execute user-supplied Python during validation. Prefer parsing and static analysis, or use a rigorously isolated execution service with no access to application secrets or privileged resources.

Review all flows from HTTP input to dynamic execution sinks, enforce authorization at sensitive endpoints, apply least privilege, and use static analysis and runtime monitoring to detect unsafe code-execution paths.

Find out what's already
exploitable in your codebase.