Skip to main content
Vulnerability Database/CVE-2025-55214

CVE-2025-55214: Copier Path Traversal Vulnerability

CVE-2025-55214 is a path traversal flaw in Copier library that allows malicious templates to write files outside the destination path. This post explains its impact, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2025-55214 Overview

Copier is a Python library and command-line tool for rendering project templates. CVE-2025-55214 is a path traversal vulnerability [CWE-22] affecting Copier versions 7.1.0 through 9.9.0. A template marked as "safe" (one that does not require the --UNSAFE/--trust flag) can write files outside the intended destination directory. The flaw arises from rendered directory paths that resolve to relative parent paths or absolute paths, constructed using Copier's built-in pathjoin Jinja filter and the _copier_conf.sep variable. A malicious template author can use this to overwrite arbitrary files that the invoking user has permission to modify. The issue is fixed in Copier 9.9.1.

Critical Impact

A malicious "safe" template can overwrite arbitrary files on the host filesystem, subject to the executing user's write permissions, undermining Copier's safety guarantee.

Affected Products

  • Copier >= 7.1.0, < 9.9.1
  • Projects generated or updated from untrusted Copier templates
  • Any CI/CD pipeline invoking Copier against third-party templates

Discovery Timeline

  • 2025-08-18 - CVE-2025-55214 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-55214

Vulnerability Analysis

Copier distinguishes between "safe" and "unsafe" templates. Unsafe templates require the user to pass --UNSAFE or --trust because they use features such as custom Jinja extensions. Safe templates are assumed to be constrained to writing within the destination directory selected by the user.

The vulnerability breaks that assumption. During rendering, Copier evaluates directory names from Jinja expressions and joins them to the destination path. If a template renders a directory name containing parent-directory segments (..) or an absolute path, the resulting write target escapes the destination root. The template author can produce such paths using Copier's pathjoin Jinja filter together with _copier_conf.sep, the platform-native path separator.

The outcome is arbitrary file write within the invoking user's permission scope. On developer workstations this can overwrite source code, shell configuration files, or SSH keys. In CI runners, it can tamper with pipeline artifacts or credentials mounted into the workspace.

Root Cause

Copier did not validate that rendered path components stayed within the destination directory before writing. The patch introduces a ForbiddenPathError and rejects any rendered path that resolves outside the project root, using PurePosixPath and PureWindowsPath to normalize across platforms.

Attack Vector

Exploitation requires a user to render a crafted template with Copier. The attacker publishes a template (for example on a public repository) that embeds malicious directory expressions. When the victim runs copier copy or copier update against it without the --UNSAFE flag, Copier writes files to attacker-chosen locations outside the destination.

python
# Patch excerpt - copier/errors.py
class ForbiddenPathError(PathError):
    """The path is forbidden in the given context."""

    def __init__(self, *, path: Path) -> None:
        super().__init__(f'"{path}" is forbidden')


class ExtensionNotFoundError(UserMessageError):
    """Extensions listed in the configuration could not be loaded."""
python
# Patch excerpt - copier/_main.py
from pathlib import Path, PurePath, PurePosixPath, PureWindowsPath

Source: GitHub commit fdbc0167

The fix imports both PurePosixPath and PureWindowsPath to normalize rendered path segments and raises ForbiddenPathError whenever a rendered target would escape the destination directory.

Detection Methods for CVE-2025-55214

Indicators of Compromise

  • Files modified outside the Copier destination directory immediately after a copier copy or copier update invocation.
  • Template .copier-answers.yml files whose source references untrusted or unknown template repositories.
  • Copier template source trees containing directory names that invoke the pathjoin filter together with _copier_conf.sep and .. segments.

Detection Strategies

  • Inventory installed Copier versions across developer workstations and CI images; flag any version < 9.9.1.
  • Audit Copier templates referenced by internal projects for Jinja expressions that build directory names dynamically, particularly those using pathjoin or absolute path separators.
  • Monitor file integrity on sensitive paths (~/.ssh/, ~/.config/, CI secret mounts) around template rendering activity.

Monitoring Recommendations

  • Enable filesystem auditing on developer and build-agent home directories to capture writes originating from Python processes executing copier.
  • Log Copier CLI invocations in CI pipelines, including the template source URL and resolved commit hash.
  • Alert on CI job steps that modify files outside the declared workspace directory.

How to Mitigate CVE-2025-55214

Immediate Actions Required

  • Upgrade Copier to version 9.9.1 or later in all developer and CI environments.
  • Re-run known-good templates against trusted destinations and compare output to detect prior tampering.
  • Review recent uses of third-party Copier templates and inspect the resulting projects for unexpected file writes.

Patch Information

The vulnerability is fixed in Copier 9.9.1. The fix in commit fdbc0167 adds a ForbiddenPathError and validates that each rendered directory path resolves within the destination directory before any file is written. See the GitHub Security Advisory GHSA-p7q8-grrj-3m8w and the upstream commit for details.

Workarounds

  • Only render Copier templates from trusted, reviewed sources until the upgrade is complete.
  • Execute copier inside a sandboxed environment such as a container or ephemeral user account with no access to sensitive files outside the project directory.
  • Pin internal projects to specific template commits and review template changes before updating.
bash
# Upgrade Copier to the patched release
pip install --upgrade "copier>=9.9.1"

# Verify installed version
copier --version

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.