VAITP Dataset

← Back to the dataset

CVE-2026-57171

Path traversal in Trestle's generate commands allows arbitrary file write/overwrite.

  • CVSS 7.7
  • 22
  • Input Validation and Sanitization
  • Remote

Compliance-trestle (Trestle) is a Python SDK and command-line tool for managing OSCAL compliance documents. In versions before 3.12.4 and versions 4.0.0 through 4.0.3, the catalog-generate, profile-generate, and ssp-generate author commands write generated Markdown to an attacker-influenced output path without path-traversal validation, allowing arbitrary file write outside the Trestle workspace. These commands join the user-supplied output argument onto the Trestle root and write to the result, but guard it only with an is_directory_name_allowed() task-name-collision check rather than the PathSecurityValidator.validate_local_path() guard used by the jinja command, so an absolute path or one containing traversal sequences escapes the workspace and writes files under an attacker-chosen location as the invoking process owner. The security boundary is crossed when a trusted CI job, shared service, or wrapper derives the output argument from repository-controlled, tenant-controlled, or otherwise untrusted data while expecting output to stay inside the workspace. When –force-overwrite is used, the selected output directory is first recursively deleted, extending the primitive to destruction of an attacker-chosen directory tree and enabling indirect code execution by overwriting files a pipeline later runs. This issue is fixed in versions 3.12.4 and 4.1.0.

CWE
22
CVSS base score
7.7
Published
2026-08-26
OWASP
A04 Insecure Design
Orthogonal defect classification
Interface
Code defect classification
Missing Check
Category
Input Validation and Sanitization
Subcategory
Path Traversal
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Compliance-trestle
Fixed by upgrading
Yes

Solution

Upgrade to Trestle v3.12.4 or later (v4.1.0 or later).

Vulnerable code sample

from pathlib import Path

# Mock of Trestle's workspace root
TRESEL_ROOT = Path("/workspace/trestle")

def is_directory_name_allowed(name: str) -> bool:
    # Simplified check that only prevents name collisions, not traversal
    return name not in {"existing-dir"}

def generate_markdown(output: str, content: str) -> None:
    # VULNERABLE: writes to attacker-controlled path without traversal validation
    if not is_directory_name_allowed(output):
        raise ValueError("Directory name not allowed")
    out_path = TRESEL_ROOT / output
    out_path.parent.mkdir(parents=True, exist_ok=True)
    out_path.write_text(content)

Patched code sample

from pathlib import Path

# Mock of Trestle's workspace root
TRESEL_ROOT = Path("/workspace/trestle")

def is_directory_name_allowed(name: str) -> bool:
    return name not in {"existing-dir"}

class PathSecurityValidator:
    @staticmethod
    def validate_local_path(root: Path, target: Path) -> None:
        # Ensure target is within root to prevent path traversal
        if not target.resolve().is_relative_to(root.resolve()):
            raise ValueError("Path traversal detected")

def generate_markdown(output: str, content: str) -> None:
    # FIX: validates output path against workspace root
    out_path = TRESEL_ROOT / output
    PathSecurityValidator.validate_local_path(TRESEL_ROOT, out_path)
    out_path.parent.mkdir(parents=True, exist_ok=True)
    out_path.write_text(content)

Cite this entry

@misc{vaitp:cve202657171,
  title        = {{Path traversal in Trestle's generate commands allows arbitrary file write/overwrite.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-57171},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-57171/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::