Summary
A path traversal vulnerability in the create_sketch tool of processing-claude-mcp-bridge allows attackers to manipulate the sketch_name argument to access unintended filesystem paths.
When user-controlled values are concatenated into file paths without proper validation, a remote attacker can potentially read, overwrite, or create files outside the intended sketch directory, depending on deployment permissions.
Affected context
The issue occurs in deployments of processing-claude-mcp-bridge (up to commit e017b20a4b592a45531a6392f494007f04e661bd) where the processing_server.py component exposes the create_sketch tool over a network-accessible interface.
The vulnerability manifests when the sketch_name argument is accepted from a remote client and used to construct file system paths for sketch creation or manipulation without first normalizing and constraining it to a dedicated base directory.
Actual impact depends on the operating system, runtime permissions of the server process, and any filesystem sandboxing or containerization in place.
Exploit preconditions
- Attack surface: Network-accessible interface exposing the create_sketch tool (e.g., HTTP, RPC, or MCP endpoint).
- Required access: Ability to invoke the create_sketch functionality and supply an attacker-controlled sketch_name parameter; no local shell access is required.
- Trigger point: Server-side code in processing_server.py combines sketch_name with a base path (or implicitly relies on the working directory) and performs file system operations (create, open, write, list).
- Why exploitation is possible: The sketch_name argument is not adequately sanitized, canonicalized, or restricted to a safe subtree. As a result, traversal sequences (such as "../") or absolute path constructs can bypass the intended sketch directory boundaries and target arbitrary paths within the server's accessible filesystem.
Why this happens
The underlying bug is a classic path traversal flaw aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory.
At an abstract level, the application treats user input as a trusted component of a file path, concatenating sketch_name into paths without:
- Canonicalizing the resulting path,
- Validating that it remains within an allowed root directory, or
- Rejecting dangerous characters, segments, or absolute path patterns.
This design assumes that user-provided path fragments will always refer to valid sketch names and remain inside a specific directory. Because the filesystem does not enforce that policy itself, attackers can encode traversal sequences to escape the intended directory and interact with other files reachable by the server's permissions.
Potential impact
- Reading sensitive files that are readable by the server process (e.g., configuration files, logs, or access tokens).
- Overwriting or creating files in directories writable by the server, which can lead to data corruption or planting malicious content.
- Interfering with application behavior by modifying application-specific files or temporary data.
- Assisting in further compromise by exposing secrets, keys, or credentials that may be reused elsewhere.
- Potentially enabling limited denial of service by clobbering critical application or state files.
General mitigation guidance
Effective mitigation focuses on constraining how user input influences file paths and enforcing strict directory boundaries:
- Enforce a fixed base directory: Construct all sketch-related file paths relative to a predefined root (e.g., a "sketches" directory), and never allow callers to override that root.
- Canonicalize and validate paths: Normalize the combined path (resolving ".", "..", and symbolic links where feasible) and verify that the canonical result still resides under the permitted base directory before performing any file operation.
- Reject unsafe patterns: Validate sketch_name against a conservative allowlist (e.g., alphanumeric characters plus a small set of safe separators) and reject any input containing traversal sequences, absolute path markers, or drive specifiers.
- Use high-level path utilities: Prefer safe path-joining and normalization APIs (e.g., pathlib) over manual string concatenation, and apply policy checks after joining.
- Apply least privilege: Run the server with minimal filesystem privileges and, where possible, within a container or sandbox with a restricted view of the host filesystem. This reduces the blast radius if traversal validation fails.
How teams detect issues like this
Detection can combine static inspection, dynamic testing, and process-level monitoring:
- Static analysis: Configure code scanning rules to flag:
- Direct concatenation of user-controlled variables into file paths.
- Uses of open(), os.remove(), os.mkdir(), file writes, or similar operations where path arguments trace back to network or user input.
- Absence of canonicalization and directory boundary checks around sketch_name handling.
- Code review heuristics: During reviews, pay special attention to:
- Any file system access in endpoints or tools that accept path-like parameters.
- Path construction logic in processing_server.py and related utility modules.
- Lack of explicit base directory enforcement or allowlist validation.
- Dynamic testing and fuzzing: Use security testing tools or targeted scripts to:
- Invoke create_sketch with traversal payloads (using "../" or absolute paths) and confirm that access is denied.
- Monitor for unexpected file creations or modifications outside the intended sketch directory in test environments.
- Runtime monitoring: Configure logging to capture path arguments for sketch creation and alert on anomalous patterns (e.g., paths containing traversal sequences or pointing outside expected directories), while respecting privacy and data protection requirements.

