Описание
PraisonAI Vulnerable to Sensitive Environment Variable Exposure via Untrusted MCP Subprocess Execution
PraisonAI’s MCP (Model Context Protocol) integration allows spawning background servers via stdio using user-supplied command strings (e.g., MCP("npx -y @smithery/cli ...")). These commands are executed through Python’s subprocess module. By default, the implementation forwards the entire parent process environment to the spawned subprocess:
As a result, any MCP command executed in this manner inherits all environment variables from the host process, including sensitive data such as API keys, authentication tokens, and database credentials.
This behavior introduces a security risk when untrusted or third-party commands are used. In common scenarios where MCP tools are invoked via package runners such as npx -y, arbitrary code from external or potentially compromised packages may execute with access to these inherited environment variables. This creates a risk of unintended credential exposure and enables potential supply chain attacks through silent exfiltration of secrets.
Reproducing the Attack
- Export a secret key:
export SUPER_SECRET_KEY=123456_pwned - Start an MCP tool locally that dumps its inherited environment:
- Observe that
SUPER_SECRET_KEYand all foundational LLM keys are printed, indicating they've been leaked to the untrusted command.
##POC
Real-world Impact
Developers who integrate third-party or unvetted MCP servers via CLI-based commands (such as npx or pipx) risk exposing sensitive credentials stored in environment variables. Because these subprocesses inherit the host environment by default, any executed MCP command can access secrets defined in .env files or runtime configurations.
In supply chain attack scenarios, a malicious or compromised package can read os.environ and silently exfiltrate sensitive data, including API keys (e.g., OpenAI, Anthropic), database connection strings, and cloud credentials (e.g., AWS access keys). This can lead to unauthorized access to external services, data breaches, and potential infrastructure compromise without any visible indication to the user.
Remediation Steps
- Explicit API Exclusions: Sanitize
envdictionaries before giving them tosubprocess. Explicitly remove known sensitive API keys (OPENAI_API_KEY, keys matching*_API_KEY,*_TOKEN, etc.) from child processes unless explicitly whitelisted by the user. - Provide a strict allowlist parameter for variables that the developer intends to pass down.
- Advise users in the documentation about the risks of
npx -yin MCP tool loading.
Пакеты
PraisonAI
< 4.5.128
4.5.128
Связанные уязвимости
PraisonAI is a multi-agent teams system. Prior to 4.5.128, PraisonAI’s MCP (Model Context Protocol) integration allows spawning background servers via stdio using user-supplied command strings (e.g., MCP("npx -y @smithery/cli ...")). These commands are executed through Python’s subprocess module. By default, the implementation forwards the entire parent process environment to the spawned subprocess. As a result, any MCP command executed in this manner inherits all environment variables from the host process, including sensitive data such as API keys, authentication tokens, and database credentials. This behavior introduces a security risk when untrusted or third-party commands are used. In common scenarios where MCP tools are invoked via package runners such as npx -y, arbitrary code from external or potentially compromised packages may execute with access to these inherited environment variables. This creates a risk of unintended credential exposure and enables potential supply ch