Copier Arbitrary File Read/Write Vulnerability in Jinja Context

Vulnerability

A vulnerability in the Copier library and CLI application, prior to version 9.9.1, allows safe templates to read and write arbitrary files. This issue arises because Copier exposes certain pathlib.Path objects in the Jinja context, which have unrestricted I/O methods. As a result, the intended security model for filesystem access is ineffective. The vulnerability is fixed in version 9.9.1.

Impact

Exploitation of this vulnerability could lead to unauthorized reading or writing of files on the filesystem. For example, a malicious template could read sensitive information like SSH keys from known locations, encode them to evade detection, and then prompt the user to upload the project to a public repository, where the template author could retrieve the secrets. Similarly, the vulnerability could be used to overwrite or delete files, causing potential disruption or data loss.

Reproduction

The vulnerability can be reproduced by creating a template that accesses filesystem paths through the exposed Jinja context variables. For instance, a template could be crafted to read a secret file, such as an SSH key, by resolving the path to the file and using the read_text method. This could be done by writing a Jinja template that includes the necessary logic to access and read the file, and then executing the template with Copier. The same approach can be used to write to files or delete them, demonstrating the lack of proper access controls.

Remediation

Users should update to Copier version 9.9.1 or later, where this vulnerability has been fixed.

Added: Aug 18, 2025, 5:24 PM
Updated: Aug 18, 2025, 5:24 PM

Vulnerability Rating

Custom Algorithm
spread
0.0
impact
7.5
exploitability
5.8
remediation
7.7
relevance
0.4
threat
6.4
urgency
2.9
incentive
1.7

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.