Summary
gmx-vmd-mcp up to version 0.1.0 contains a command injection vulnerability in the launch_vmd_gui_tool function of mcp_server.py, where the structure_file and trajectory_file arguments are incorporated into a shell command without proper sanitization.
A remote attacker who can influence these arguments may execute arbitrary commands on the hosting system with the privileges of the gmx-vmd-mcp process.
Affected context
The vulnerability occurs in deployments of gmx-vmd-mcp (up to 0.1.0) where the VMD Launch Handler exposes functionality that allows a client to specify or control structure_file and/or trajectory_file parameters.
It typically appears when:
- The backend constructs shell commands to launch VMD or related tools.
- User- or network-supplied file paths are passed directly into those shell commands.
- No strict validation, escaping, or safe process invocation is enforced for these parameters.
The risk is higher in environments where the service is reachable over a network and runs with elevated or shared compute privileges.
Exploit preconditions
- Attack surface: Network-accessible interface to the VMD Launch Handler (e.g., API endpoint, RPC, or similar mechanism).
- Required access: Ability to send requests or messages that control
structure_fileand/ortrajectory_filevalues. - Trigger point: Invocation of
launch_vmd_gui_toolinmcp_server.py, which uses the supplied values when constructing and executing a command. - Why exploitation is possible: The implementation appears to interpolate these arguments directly into a shell command (or equivalent), without rigorous escaping or validation, allowing crafted input to break out of the intended command context and inject additional commands.
Why this happens
This vulnerability stems from constructing shell commands using untrusted input without robust sanitization or safe APIs.
Instead of passing file arguments as isolated parameters to a process execution API, the code likely builds a command string that includes structure_file and trajectory_file directly.
That pattern maps to:
- CWE-77: Command Injection, where special shell meta-characters in user input alter the structure of the executed command.
- CWE-74: Improper Neutralization of Special Elements in Output, as the unsafe interpolation fails to neutralize characters that change the intended command.
Conceptually, the bug is treating file path inputs as though they were inert text, when in reality they are interpreted by the shell as executable syntax.
Potential impact
- Execution of arbitrary OS commands under the permissions of the gmx-vmd-mcp service.
- Reading, modifying, or deleting files accessible to the service account.
- Pivoting to other internal systems or services from the compromised host.
- Installing backdoors or persistent tooling on the affected machine.
- Disruption of computational workflows, including termination or manipulation of simulations or visualization jobs.
General mitigation guidance
Effective mitigation focuses on eliminating shell interpretation of untrusted input and hardening how external tools are invoked:
- Use process execution APIs that accept argument lists (e.g., direct exec calls) instead of building shell command strings.
- Treat all file-related parameters as untrusted and validate them strictly (e.g., whitelisted directories, allowed extensions, normalized paths).
- Reject or escape shell metacharacters and other control characters in any input that might reach a command context.
- Apply least-privilege principles so the gmx-vmd-mcp service runs with minimal filesystem and OS permissions.
- Introduce clear trust boundaries between the network-facing interface and any process-launch functionality, with explicit validation at the boundary.
How teams detect issues like this
Detecting this class of vulnerability and its exploitation can combine code-focused and operational approaches:
- Static analysis: Flag string-based command constructions that incorporate variables derived from request parameters, especially in
mcp_server.pyand VMD launch paths. - Code review signals: Look for calls that use
shell=True, string concatenation or formatting of commands, and any use of user-controlled file parameters in these commands. - Policy enforcement: Enforce coding guidelines that mandate argument-list-based process execution and prohibit direct shell interpolation of untrusted input.
- Runtime monitoring: Monitor process execution logs and system audit trails for unusual commands spawned by the gmx-vmd-mcp process, and for suspicious characters in file arguments.

