Summary
Chainlit deployments that enable the MCP feature may expose an unauthenticated endpoint that accepts attacker-controlled stdio command data. An attacker can abuse supported command-line behavior to execute arbitrary shell commands with the privileges of the Chainlit process.
Affected context
The issue occurs in Chainlit deployments where features.mcp.enabled is set to true and the MCP POST endpoint is reachable. It is especially risky when stdio transport is enabled, command restrictions are absent or incomplete, and the endpoint is exposed without an authentication or authorization boundary.
Exploit preconditions
- Attack surface: The unauthenticated POST
/mcpendpoint - Required access: Network access to the exposed Chainlit service; no application authentication may be required
- Trigger point: Processing a user-controlled
fullCommandfor MCP stdio transport - Why exploitation is possible: Validation checks the executable name but does not adequately constrain arguments, while an unset executable allowlist may permit any executable
Why this happens
The vulnerability results from incomplete validation of a command constructed from user-controlled input. The implementation validates only part of the command and forwards unchecked arguments to the stdio server configuration. This permits shell-capable command-line options, such as those supported by npx, to alter execution behavior and run attacker-controlled commands. The pattern maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command.
Potential impact
- An attacker may execute arbitrary operating-system commands
- The Chainlit process and its accessible application data could be compromised
- Secrets, tokens, or configuration data may be exposed
- The vulnerable service could be used for lateral movement or persistence
- Connected conversational AI services and integrations could be manipulated
General mitigation guidance
Mitigation generally focuses on removing unauthenticated command-execution paths and treating all MCP command data as untrusted.
Common defensive patterns include:
- Require authentication and authorization before exposing MCP endpoints
- Prefer fixed, predefined server commands over user-supplied command strings
- Avoid shell-capable command interpreters and argument forms
- Validate executable paths and every argument against a strict schema and allowlist
- Treat an unset allowlist as deny-by-default rather than permitting all executables
- Run Chainlit with a dedicated, minimally privileged identity and restricted filesystem access
- Isolate MCP workers from sensitive networks, credentials, and host resources
How teams detect issues like this
Detection can combine application review, runtime monitoring, and policy enforcement:
- Search source code for subprocess or stdio server creation that receives request-derived command values
- Flag validation routines that check executable names but not arguments or shell metacharacters
- Review configurations for enabled MCP features, exposed endpoints, missing authentication, and unset executable allowlists
- Monitor process creation from Chainlit workers, including unexpected interpreters, package runners, network utilities, and child processes
- Enforce CI policies that reject shell execution from request-controlled data
- Use static analysis and automated code review tools to identify command construction and incomplete allowlist validation

