/

CVE-2026-62999

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in Copier Trusted Template URLs

CVE-2026-62999

Deferred

Vulnerability type

Category:

Path Traversal and Input Validation

CWE:

CWE-22, CWE-180

Impact:

Execution of untrusted template logic

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Copier's template URL handling allows percent-encoded parent-directory segments and path separators to bypass trusted repository prefix checks.

Under certain URL encoding conditions, templates from untrusted repositories can be treated as trusted, enabling unsafe template features to run after user interaction.

Affected context

This vulnerability affects environments where Copier is used to render project templates from URLs and relies on trusted repository prefixes for security.

It manifests when template URLs include percent-encoded .. segments or encoded path separators that are validated in their encoded form, but later decoded by HTTP or Git transports.

The issue is most relevant in workflows that permit templates with advanced or unsafe features under the assumption they originate only from trusted repositories.

Exploit preconditions

  • Attack surface: Template URL input to Copier (CLI or library)
  • Required access: Ability to supply or influence the template URL used by Copier
  • Trigger point: Prefix validation on an encoded URL followed by path decoding by HTTP server or Git transport
  • Why exploitation is possible: The trust check is performed on the raw, encoded path, while actual repository resolution uses a decoded path, allowing traversal or redirection outside the trusted prefix.

Why this happens

The core issue is a mismatch between validation and interpretation of user-supplied paths, aligning with CWE-22 (Improper Limitation of a Pathname to a Restricted Directory) and CWE-180 (Incorrect Regular Expression or Input Validation).

Copier checks whether the encoded template URL starts with a trusted prefix, but does not normalize or decode the path before enforcing this restriction.

Downstream HTTP or Git transports then decode percent-encoded parent-directory segments and path separators, effectively changing the resolved repository location and bypassing the original trust boundary.

This pattern reflects a general class of bugs where validation is applied to one representation of input (encoded) and execution or access control is performed on another (decoded or normalized).

Potential impact

  • Templates from untrusted repositories may run with the same privileges as trusted templates
  • Unsafe template features can be executed, potentially running arbitrary code or commands during project generation
  • Project scaffolds may include malicious configuration, scripts, or dependencies
  • Users and build environments can be exposed to supply-chain attacks via compromised template sources

General mitigation guidance

Effective mitigation focuses on tightly controlling path resolution and trust boundaries around template URLs.

Useful defensive patterns include:

  • Normalizing and decoding paths before applying prefix or trust checks, ensuring validation matches the final resolved location
  • Rejecting or strictly constraining the use of parent-directory segments and encoded path separators in template URLs
  • Applying a clear separation between trusted and untrusted templates, disabling unsafe or code-executing features for untrusted sources by default
  • Running template rendering with least privilege, so that even if untrusted logic executes, its ability to affect the broader system is minimized
  • Treating network-retrieved templates as untrusted unless explicitly verified, and reducing reliance on implicit trust based on path segments alone

How teams detect issues like this

Organizations can identify similar vulnerabilities by:

  • Reviewing code paths where URLs or filesystem paths are validated in one representation (e.g., encoded) but used after transformation (e.g., decoded or normalized)
  • Applying static analysis rules that flag reliance on prefix checks without normalization for path, URL, or repository validation
  • Inspecting template handling logic for any allowance of .. segments or encoded path separators reaching repository resolution layers
  • Enforcing security policies that require centralized path normalization utilities and forbid ad-hoc trust checks on raw input strings
  • Using automated code review tools configured to detect CWE-22 and CWE-180 patterns, especially around Git and HTTP transport integration

Sources

SourceLink
github.comgithub.com/copier-org/copier/commit/7408f0d6287a7bf452715fd9f25dc54eaba3c295
github.comgithub.com/copier-org/copier/releases/tag/v9.17.0
github.comgithub.com/copier-org/copier/security/advisories/GHSA-34mv-rjq9-5mch

Frequently asked

questions

It is exploitable through any interface where an attacker can influence the template URL provided to Copier, which can include remote vectors such as scripts, automation configs, or shared commands, but it still requires the victim to run Copier with that URL.

The attacker needs the ability to supply or modify the template URL that a user or automated system passes to Copier.

No direct access to the local filesystem is required beyond controlling the URL used to fetch and render the template.

The safest approach is to normalize and decode paths before enforcing trust checks, and to ensure that repository selection logic uses the same canonical representation that validation uses.

Additionally, disallow or strictly constrain traversal patterns (..) and encoded separators in contexts where trust boundaries depend on directory prefixes.

Future implementations should adopt consistent input normalization before any authorization or trust decision, use established libraries for safe path and URL handling, and avoid relying solely on string prefix checks for security.

Coupling this with systematic code review for CWE-22/CWE-180 patterns and automated tests around encoded path handling reduces the risk of similar bugs.

Find out what's already
exploitable in your codebase.