Summary
A path traversal vulnerability in the @tinacms/graphql module allows unauthenticated users to write or overwrite arbitrary files within the project root by abusing the relativePath parameter in GraphQL mutations.
Under vulnerable configurations, an attacker can replace critical server files or sabotage build scripts, which may ultimately enable arbitrary command execution during deployment or build processes.
Affected context
This issue affects applications using Tina as a headless CMS where the @tinacms/graphql API is exposed and accepts user-supplied relativePath values for file-based content operations.
The vulnerability manifests when file write operations derive filesystem paths from client-controlled input without robust normalization and enforcement of allowed directories.
It is most relevant in environments where the project root contains build scripts, configuration files, or other sensitive assets that can influence server behavior or deployment.
Exploit preconditions
- Attack surface: Publicly exposed @tinacms/graphql endpoint handling content mutations.
- Required access: No authentication required; any network-accessible user can send crafted GraphQL mutations.
- Trigger point: File creation or update mutations that take a relativePath parameter to determine the target file location.
- Why exploitation is possible: The implementation trusts the relativePath input and does not sufficiently prevent directory traversal sequences (e.g., "..") or enforce strict confinement to intended content directories, allowing writes to arbitrary paths within the project root.
Why this happens
The underlying bug class is directory traversal combined with unsafe file write operations, aligning with CWE-22: Improper Limitation of a Pathname to a Restricted Directory and CWE-73: External Control of File Name or Path.
The system constructs filesystem paths for write operations directly from client-controlled relativePath values, with incomplete canonicalization and boundary checks.
Without strict validation and enforcement of an allowed base directory, attackers can escape the intended content folder and target sensitive resources under the project root, turning a content-editing feature into a generic arbitrary file writer.
Potential impact
- Overwriting application or configuration files within the project root.
- Injecting or modifying build scripts to execute attacker-controlled commands during build or deployment.
- Sabotaging application behavior by corrupting templates, content schemas, or environment-related files.
- Introducing backdoors or malicious logic into source files that are later compiled or deployed.
- Causing denial of service by corrupting critical project assets needed for startup or runtime.
General mitigation guidance
Effective mitigation focuses on constraining file operations and distrusting client-controlled paths:
- Rigorously normalize and canonicalize all file paths derived from user input before use.
- Enforce a strict, server-side configured base directory for all content operations, rejecting any path that resolves outside this directory.
- Use allowlists of permissible directories and, where practical, restrict file names or extensions to known-safe patterns.
- Separate build and deployment scripts, configuration files, and other sensitive assets from directories exposed to content editing features.
- Apply least-privilege filesystem permissions so the process handling GraphQL mutations cannot modify critical project or system files.
How teams detect issues like this
Organizations can detect and monitor this class of issue by:
- Applying static analysis rules to identify file operations that concatenate or join filesystem paths with raw user input.
- Reviewing GraphQL resolvers and API handlers for any parameters that control filenames or paths without canonicalization and boundary checks.
- Implementing security tests or fuzzing that send traversal payloads (e.g., sequences using "../") to file-related mutations to verify enforcement of directory constraints.
- Using centralized logging and alerting to detect unexpected writes to configuration files, build scripts, or other sensitive locations under the project root.

