Summary
mcpo-simple-server up to version 0.2.0 contains a relative path traversal vulnerability in the delete_shared_prompt function, allowing crafted input to escape the intended directory.
When an attacker can control the detail argument over a remote interface, they may delete or manipulate files outside the expected prompt storage path on the server.
Affected context
This vulnerability appears in deployments of getsimpletool mcpo-simple-server (≤ 0.2.0) where the prompt management service is exposed over a network interface.
The delete_shared_prompt function in src/mcpo_simple_server/services/prompt_manager/base_manager.py operates on filesystem paths derived from the user-controlled detail parameter, without properly constraining them to a safe base directory.
Any environment where untrusted users can invoke this API is at risk, particularly multi-tenant or Internet-exposed instances.
Exploit preconditions
- Attack surface: Network-exposed API or HTTP endpoint that invokes delete_shared_prompt
- Required access: Ability to call the relevant delete/shared-prompt operation with a controlled detail value (e.g., via web UI, REST endpoint, or RPC)
- Trigger point: Submission of a specially crafted detail argument containing relative path components (such as ../ segments)
- Why exploitation is possible: The server-side code constructs filesystem paths using user-supplied values without canonicalization and enforcement of a fixed base directory, enabling traversal outside the intended storage location.
Why this happens
The core issue is improper restriction of file paths constructed from user-controlled input, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') and CWE-23: Relative Path Traversal.
The delete_shared_prompt function likely concatenates the detail parameter with a base path or uses it directly when performing filesystem operations (such as delete or open) without:
- normalizing the resulting path
- validating that the final, canonical path still resides under an allowed directory
- stripping or rejecting relative traversal sequences like ../
This insecure pattern allows attackers to escape the intended directory boundary and target arbitrary paths on the filesystem that the server process can access.
Potential impact
- Deletion of files outside the intended prompt directory that are writable by the server process
- Manipulation or overwriting of files if the code allows write or create operations along the same path construction logic
- Disruption of application functionality by removing configuration, data, or prompt files
- Potential denial of service if critical application files or state are removed
- In some deployments, leverage as a stepping stone for further compromise (e.g., deleting logs, tampering with scripts, or interfering with security controls)
General mitigation guidance
Effective mitigation focuses on constraining all filesystem operations to vetted directories and treating path components as untrusted data:
- Use a fixed, server-side configured base directory for all prompt-related files and never allow clients to supply absolute paths.
- Normalize and canonicalize constructed paths (resolving symbolic links and relative components) before use, then enforce that the final path still resides under the allowed base directory.
- Reject or sanitize any user input containing disallowed patterns such as ../, leading slashes, drive letters, or null bytes.
- Represent prompts by opaque identifiers (IDs or UUIDs) rather than direct filenames, and map IDs to paths on the server side.
- Apply least-privilege to the server process so that even if traversal is attempted, access to sensitive system locations is minimized.
- Centralize file access logic behind a safe abstraction that enforces directory boundaries, rather than assembling paths ad hoc.
How teams detect issues like this
Organizations can detect and monitor for this class of issue with a combination of static and dynamic techniques:
- Static analysis: Configure SAST tools or custom rules to flag string concatenation of user input into filesystem APIs (open, delete, remove, os.path.join, etc.) without validation or canonicalization.
- Code review: During manual review, examine path-handling functions (such as delete_shared_prompt) and look for:
- direct use of request parameters in path construction
- absence of checks that ensure the final path is under a known safe directory
- missing normalization steps and lack of a central file-access abstraction
- Runtime monitoring: Use application logs or WAF rules to detect suspicious path patterns (../, ../../, URL-encoded traversal sequences) in parameters reaching file-related endpoints.
- Security testing: Incorporate path traversal test cases into API and integration tests to exercise endpoints that perform file operations, and automatically fail builds if traversal strings are not correctly rejected.

