VAITP Dataset

← Back to the dataset

CVE-2026-45018

Unauthenticated MCP endpoint allows arbitrary command execution via npx -c

  • CVSS 9.8
  • CWE-78
  • Input Validation and Sanitization
  • Remote

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 validate_mcp_command() function in backend/chainlit/mcp.py checks only the executable name against config.features.mcp.stdio.allowed_executables 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 allowed_executables is unset, its None default is treated as allowing every executable. This issue is fixed in version 2.12.0.

CVSS base score
9.8
Published
2026-08-25
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Incorrect Check
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Chainlit
Fixed by upgrading
Yes

Solution

Upgrade Chainlit to version 2.12.0 or later.

Vulnerable code sample

import shlex
from typing import List, Optional

def validate_mcp_command(full_command: str, allowed_executables: Optional[List[str]] = None) -> List[str]:
    # VULNERABLE: allowed_executables default None is treated as allowing every executable
    parts = shlex.split(full_command)
    if not parts:
        raise ValueError("Empty command")
    exe = parts[0]
    if allowed_executables and exe not in allowed_executables:
        raise PermissionError(f"Executable {exe} not allowed")
    # arguments are passed unchecked to the server
    return parts

Patched code sample

import shlex
from typing import List, Optional

def validate_mcp_command(full_command: str, allowed_executables: Optional[List[str]] = None) -> List[str]:
    # FIX: treat None as empty whitelist and discard unchecked arguments
    parts = shlex.split(full_command)
    if not parts:
        raise ValueError("Empty command")
    exe = parts[0]
    whitelist = allowed_executables or []
    if exe not in whitelist:
        raise PermissionError(f"Executable {exe} not allowed")
    # only return the executable; arguments are stripped to prevent injection
    return [exe]

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

  • Merge commit from fork (Chainlit/chainlit)
    backend/chainlit/config.py, backend/chainlit/config.py · load_settings, backend/chainlit/mcp.py, backend/chainlit/server.py, backend/chainlit/server.py · connect_mcp, backend/chainlit/server.py · project_settings, backend/chainlit/session.py, backend/chainlit/session.py · McpSession.close, backend/chainlit/types.py, backend/chainlit/version.py, cypress/e2e/config_overrides/main.py, cypress/e2e/config_overrides/main.py · chat_profile

Cite this entry

@misc{vaitp:cve202645018,
  title        = {{Unauthenticated MCP endpoint allows arbitrary command execution via npx -c}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-45018},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-45018/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.