Summary
TinaCMS's @tinacms/graphql FilesystemBridge performs string-based path containment checks that fail to account for symlink and junction resolution, allowing paths that appear to stay under the content root to actually escape it on disk.
An attacker who can influence content paths or file structures under the CMS content root may be able to read, write, delete, or enumerate files outside the intended directory sandbox. This becomes risky when the CMS is exposed to untrusted authors or automated workflows with access to the affected filesystem operations.
Affected context
The vulnerability occurs in the FilesystemBridge component of @tinacms/graphql when it enforces a content root using string-based path prefix checks rather than resolving the real filesystem path.
It affects deployments where:
- TinaCMS is used with a filesystem-backed content root, and
- Symlinks or junctions exist somewhere under that root (intentionally or accidentally), and
- Application logic relies on FilesystemBridge.get(), put(), delete(), or glob() to enforce that all file operations remain inside the configured content root.
In these conditions, paths that look safe (e.g., content/posts/pivot/owned.md) can actually target locations outside the CMS root once symlinks or junctions are resolved by the OS.
Exploit preconditions
- Attack surface: TinaCMS instances using @tinacms/graphql with FilesystemBridge for content operations.
- Required access:
- Ability to create or influence symlink/junctions under the content root, or
- Ability to choose or manipulate file paths operated on by FilesystemBridge (e.g., via content slugs, file names, or repository-controlled structures).
- Trigger point:
- Calls to FilesystemBridge methods such as:
get()for reading file contentsput()for writing or updating contentdelete()for removal of filesglob()for listing files- These calls are made with paths that traverse through or terminate in symlink/junction-controlled locations.
- Why exploitation is possible:
- The bridge validates that requested paths are "inside" the base directory using string comparison (e.g., checking that the requested path starts with the base path).
- It does not canonicalize or resolve symlinks/junctions to their real filesystem targets before applying the containment check.
- As a result, the system treats a path as safe even when the resolved real path escapes the intended root via existing symlink/junction links, enabling directory traversal relative to the true filesystem layout.
Why this happens
The core issue is a mismatch between logical path validation and actual filesystem resolution.
FilesystemBridge assumes that string-based checks like "path starts with basePath" are sufficient to guarantee that file operations stay inside a configured content root. This pattern overlooks the fact that the OS resolves symlinks and junctions at the filesystem layer, potentially redirecting an apparently safe path to an arbitrary location.
This aligns with:
- CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') — because the code attempts to restrict paths to a directory but fails to account for all traversal mechanisms, including links.
- CWE-59: Improper Link Resolution Before File Access ('Link Following') — because access decisions are made based on pre-resolution paths instead of the canonical, link-resolved paths that the OS will actually act upon.
The insecure pattern is: access control based on unnormalized, non-canonical paths without resolving links and without verifying that the final target remains under the intended root.
Potential impact
- Read access to files outside the intended CMS content root, potentially including configuration files, application code, or environment-specific assets.
- Unauthorized modification or overwriting of files outside the content root via
put(), which can be used for content defacement, code injection, or tampering with build artifacts. - Deletion of arbitrary files reachable through symlinks/junctions using
delete(), potentially causing denial of service or data loss. - Enumeration of file structures outside the content root through
glob(), aiding further reconnaissance and targeted attacks. - Escalation from limited CMS author permissions to broader filesystem manipulation if the runtime has write access to sensitive directories.
General mitigation guidance
Effective mitigation focuses on enforcing directory boundaries based on canonical paths and minimizing trust in filesystem structure:
- Canonical path resolution:
- Resolve requested paths to their absolute, canonical form (e.g., using realpath-like APIs that follow symlinks and junctions).
- Perform containment checks on the resolved path, ensuring it still lies within the configured content root after all link resolution.
- Avoid string-only containment checks:
- Replace brittle
startsWithor substring checks with robust, path-aware comparisons (e.g., by normalizing separators, resolving..segments, and comparing directory components). - Restrict or sanitize link usage:
- Avoid or tightly control symlinks/junctions inside the CMS content root, especially those pointing to sensitive filesystem locations.
- If links must exist, explicitly validate or whitelist their targets before allowing them to be used in content paths.
- Least privilege on filesystem access:
- Run the CMS process with file permissions restricted to the content root and strictly necessary dependencies.
- Ensure the runtime user cannot modify sensitive system files or application code even if path validation fails.
- Defensive configuration and code patterns:
- Centralize all filesystem operations through a hardened abstraction that always performs canonicalization and boundary checks.
- Treat any path influenced by user input, repository content, or plugins as untrusted and subject to strict validation.
How teams detect issues like this
To detect this class of vulnerability, organizations can combine automated and manual techniques:
- Static analysis patterns:
- Flag uses of string-based path containment checks (e.g.,
path.startsWith(basePath),indexOf(basePath)) in filesystem access code. - Identify file operations (
readFile,writeFile,unlink,readdir,glob) that use unnormalized or unsanitized paths influenced by external input. - Detect direct reliance on relative paths and absence of canonicalization (
realpath,normalize,resolve) before access control decisions. - Code review signals:
- Review modules responsible for sandboxing or enforcing content roots for:
- Lack of symlink/junction handling
- Reliance on string operations instead of structured path APIs
- Assumptions that directory structure cannot be modified or linked
- Pay particular attention to bridge layers between HTTP/GraphQL handlers and filesystem utilities.
- Runtime and policy enforcement:
- Use OS-level mechanisms (AppArmor, SELinux, container volume mounts) to physically restrict the process to specific directories, reducing the impact of logical path validation bugs.
- Implement logging around filesystem operations outside the expected content tree and alert on anomalies or unexpected access patterns.
- Automated tooling:
- Incorporate security-focused linters or SAST tools that understand path traversal patterns and can highlight missing canonicalization.
- Run regular security tests that attempt to reach known external directories through symlink and junction scenarios in staging environments.

