CVE-2026-53951 Overview
CVE-2026-53951 is a path traversal vulnerability in Copier, a Python library and command-line tool for rendering project templates. The flaw affects versions 9.5.0 through 9.15.1 and is tracked under [CWE-22]. The trust setting compares a template URL against a trusted prefix using a raw str.startswith call without normalizing the path. When Copier later fetches the template, the URL is normalized, so a reference containing .. can textually match a trusted prefix while resolving to an attacker-controlled template. That template's tasks, migrations, and jinja_extensions then execute without the --trust prompt, resulting in arbitrary command execution.
Critical Impact
A malicious template reference that starts with a trusted prefix but contains .. segments bypasses Copier's trust confirmation and executes attacker-controlled code on the developer workstation or build host.
Affected Products
- Copier 9.5.0 through 9.15.1
- Projects using the trust setting in copier/_settings.py
- CI/CD pipelines and developer workstations invoking Copier with trusted prefixes
Discovery Timeline
- 2026-07-08 - CVE-2026-53951 published to NVD
- 2026-07-09 - Last updated in NVD database
- Version 9.15.2 - Copier maintainers release the patched version
Technical Details for CVE-2026-53951
Vulnerability Analysis
Copier's trust model lets users mark specific template URL prefixes as trusted, skipping the interactive --trust prompt that would otherwise gate execution of template-defined tasks, migrations, and jinja_extensions. The trust check in copier/_settings.py performs a textual comparison between the user-supplied template reference and the trusted prefix list. Because the comparison uses str.startswith with no canonicalization, two different views of the same string are used at two different points in the workflow.
When the template is actually retrieved, the reference is normalized. Local paths pass through Path.resolve(), which collapses .. segments, and https URLs are normalized by libcurl's dot-segment removal per RFC 3986. The path that gets fetched is therefore not the path that was authorized, breaking the trust decision.
Root Cause
The root cause is a Time-of-Check to Time-of-Use (TOCTOU) inconsistency between authorization and retrieval. The trust decision operates on the raw string, while the fetch operates on a normalized path. Missing input sanitization on the trust comparison [CWE-22] allows .. traversal segments to survive the check but be removed before the template is loaded.
Attack Vector
An attacker crafts a template reference whose leading characters match a prefix the victim has trusted, then appends .. segments that redirect resolution to an attacker-controlled repository or filesystem location. For example, a trusted prefix such as https://github.com/trusted-org/ can be followed by path segments containing .. that libcurl collapses to a different origin during fetch. The victim runs Copier expecting the trusted template and instead executes arbitrary commands defined in the malicious template's tasks block. Exploitation requires the victim to invoke Copier against the attacker-supplied reference, aligning with the local attack vector and user interaction requirements in the CVSS 4.0 vector.
Detection Methods for CVE-2026-53951
Indicators of Compromise
- Copier invocations where the template reference contains .. segments after a trusted prefix.
- Unexpected child processes spawned by copier such as shells, package managers, or network utilities during copy or update operations.
- Writes to ~/.ssh/, shell rc files, or CI runner secrets shortly after a Copier run.
- Outbound connections from build agents to domains not listed in the trusted prefix configuration.
Detection Strategies
- Inspect Copier configuration files and shell history for trusted prefixes and correlate them with actual template URLs fetched at runtime.
- Enable process auditing on developer and CI hosts to log the argument vector of every copier invocation.
- Alert on Copier processes that resolve template paths outside of approved directories or Git remotes.
Monitoring Recommendations
- Forward endpoint process telemetry from developer workstations and build runners to a central analytics platform for retrospective hunting on copier executions.
- Track file integrity for template cache directories under ~/.cache/copier and project-local .copier-answers.yml files.
- Monitor CI job logs for template URLs containing .., %2e%2e, or other encoded traversal patterns.
How to Mitigate CVE-2026-53951
Immediate Actions Required
- Upgrade Copier to version 9.15.2 or later on all developer workstations, container images, and CI/CD runners.
- Audit existing trusted prefix configurations and remove any prefixes that are broader than necessary.
- Review recent Copier runs for template references containing .. and investigate any resulting file or process changes.
Patch Information
Version 9.15.2 patches the flaw by normalizing template references before performing the trust prefix comparison. Release notes and the fix commit are documented in the GitHub Release v9.15.2 and the GitHub Security Advisory GHSA-9gmc-jqmh-3rvm.
Workarounds
- Remove all entries from the trust setting and require interactive --trust confirmation for every Copier run until the upgrade is applied.
- Pin Copier to 9.15.2 in project requirements.txt, pyproject.toml, and CI images to prevent regression.
- Restrict Copier execution in CI to allowlisted template repositories enforced outside of Copier, for example via network egress policies.
# Configuration example
pip install --upgrade 'copier>=9.15.2'
copier --version
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

