Summary
A path traversal vulnerability in compliance-trestle allows the trestle author jinja command to write generated files outside its intended workspace. An attacker who can control the -o/--output argument may cause files to be created or overwritten in other attacker-selected locations.
Affected context
The issue occurs in deployments that use the trestle author jinja command and permit an attacker or untrusted automation process to influence its output path. Insufficient validation of parent-directory traversal sequences, alternate path separators, and absolute paths can allow output to escape the designated workspace.
Exploit preconditions
- Attack surface: The
trestle author jinjacommand and its-o/--outputargument - Required access: Ability to invoke the command or control the output-path argument through an integrated workflow
- Trigger point: File generation when the selected output path is resolved and written
- Why exploitation is possible: The application does not adequately constrain relative traversal paths, Windows-style traversal paths, or absolute paths to the intended workspace
Why this happens
The underlying bug is insufficient path validation before writing generated content. User-controlled output paths are accepted without reliably canonicalizing the path and verifying that the resolved destination remains within the permitted workspace. This behavior maps primarily to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, with related aspects of CWE-36: Absolute Path Traversal and CWE-73: External Control of File Name or Path.
Potential impact
- An attacker may create or overwrite files outside the intended workspace
- Sensitive files could be modified if the executing identity has sufficient permissions
- Generated content could be placed in locations consumed by other tools or services
- Workflows, configurations, or source files could be corrupted
- The issue could contribute to broader compromise when combined with executable or privileged file locations
General mitigation guidance
Mitigation generally focuses on treating output paths as untrusted and enforcing a workspace boundary before any write occurs.
Common defensive patterns include:
- Resolve and canonicalize the requested path before writing
- Reject absolute paths and parent-directory traversal unless explicitly required
- Verify that the resolved destination remains beneath an approved output directory
- Prefer generated filenames or workspace-relative identifiers over arbitrary paths
- Apply allowlists for permitted output locations and file types
- Run tooling with least-privilege filesystem permissions
- Use isolated workspaces and avoid writing with elevated privileges
How teams detect issues like this
Organizations can detect this class of issue through:
- Static analysis rules for file writes using command-line or configuration-derived paths
- Code review checks for missing canonicalization and workspace-boundary validation
- Tests covering
../,..\, absolute paths, symbolic links, and mixed path separators - Runtime monitoring for writes outside approved workspace directories
- CI policies that require path validation helpers for user-controlled file operations
- Automated security review tools that flag externally controlled filenames and unrestricted filesystem writes

