CVE-2025-55214: Copier Copier's Safe Template Has Filesystem Vulnerability

MODERATE
Advisory Identifier: GHSA-p7q8-grrj-3m8w
CWE-22
Published
Advisory Summary

CVE-2025-55214 is a MODERATE copier's safe template has filesystem vulnerability (CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')) affecting Copier libraries in the PyPI ecosystem. The issue involves copier's safe template has filesystem write access outside destination path. Remediation is available by upgrading affected packages to version 9.9.1.

CVE-2025-55214 at a Glance

CVE Identifier CVE-2025-55214
GHSA Identifier GHSA-p7q8-grrj-3m8w
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')
Affected Product Copier
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2025-55214

To remediate this vulnerability, upgrade all affected Copier dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

copier fixed: 9.9.1
pip install copier>=9.9.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show copier

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2025-55214, inspect your installed packages using pip:

pip show copier

Analyze the terminal output to locate any version of Copier in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 9.9.1), your application is affected.

Note: The pip show copier command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory. In Copier, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact Copier suggests that it's safe to generate a project from a safe template, i.e. one that doesn't use [unsafe](https://copier.readthedocs.io/en/stable/configuring/#unsafe) features like custom Jinja extensions which would require passing the `--UNSAFE,--trust` flag. As it turns out, a safe template can currently write files outside the destination path where a project shall be generated or updated. This is possible when rendering a [generated directory structure](https://copier.readthedocs.io/en/stable/configuring/#generating-a-directory-structure) whose rendered path is either a relative parent path or an absolute path. Constructing such paths is possible using Copier's builtin `pathjoin` Jinja filter and its builtin `_copier_conf.sep` variable, which is the platform-native path separator. This way, a malicious template author can create a template that overwrites arbitrary files (according to the user's write permissions), e.g., to cause havoc. #### Write access via generated relative path Reproducible example: ```shell echo "foo" > forbidden.txt mkdir src/ echo "bar" > "src/{{ pathjoin('..', 'forbidden.txt') }}" uvx copier copy src/ dst/ cat forbidden.txt ``` #### Write access via generated absolute path Reproducible example: - POSIX: ```shell # Assumption: The current working directory is `/tmp/test-copier-vulnerability/` echo "foo" > forbidden.txt mkdir src/ echo "bar" > "src/{{ pathjoin(_copier_conf.sep, 'tmp', 'test-copier-vulnerability', 'forbidden.txt') }}" uvx --from copier python -O -m copier copy --overwrite src/ dst/ cat forbidden.txt ``` - Windows (PowerShell): ```powershell # Assumption: The current working directory is `C:\Users\<user>\Temp\test-copier-vulnerability` echo "foo" > forbidden.txt mkdir src Set-Content -Path src\copier.yml @' drive: type: str default: "C:" when: false '@ echo "bar" > "src\{{ pathjoin(drive, 'Users', '<user>', 'Temp', 'test-copier-vulnerability', 'forbidden.txt') }}" uvx --from copier python -O -m copier copy --overwrite src dst cat forbidden.txt ``` This scenario is slightly less severe, as Copier has a few [assertions of the destination path being relative](https://github.com/copier-org/copier/blob/d106ea543fd26e1ac1b9a3dcef3e99cc70fdf57c/copier/_main.py#L747) which would typically be raised. But `python -O` (or `PYTHONOPTIMIZE=x`) removes asserts, so these guards may be ineffective. In addition, this scenario will prompt for overwrite confirmation or require the `--overwrite` flag for non-interactive mode; yet malicious file writes might go unnoticed.

CVE-2025-55214 Affected Copier Versions

1 component(s)
Fixed Versions:
9.9.1
Product / Package Ecosystem Affected Versions Fixed Version
copier
PyPI
≥ 7.1.0
< 9.9.1
9.9.1

References

Frequently Asked Questions

What is CVE-2025-55214?
CVE-2025-55214 is a security vulnerability in Copier involving Copier's safe template has filesystem write access outside destination path under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
Which Copier versions are affected?
Affected versions include releases prior to 9.9.1 across affected packages: copier.
What version fixes CVE-2025-55214?
Upgrading to 9.9.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is copier affected?
Yes, copier is affected in releases prior to 9.9.1. Upgrade your dependency to 9.9.1 or later.
What CWE is associated with CVE-2025-55214?
CVE-2025-55214 is classified under CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') (The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.).
How can I check PyPI dependencies for CVE-2025-55214?
Run the dependency tree command: 'pip show copier'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-p7q8-grrj-3m8w",
  "modified" : "2025-08-18T21:01:07Z",
  "published" : "2025-08-18T21:01:07Z",
  "aliases" : [ "CVE-2025-55214" ],
  "summary" : "Copier's safe template has filesystem write access outside destination path",
  "details" : "### Impact\n\nCopier suggests that it's safe to generate a project from a safe template, i.e. one that doesn't use [unsafe](https://copier.readthedocs.io/en/stable/configuring/#unsafe) features like custom Jinja extensions which would require passing the `--UNSAFE,--trust` flag. As it turns out, a safe template can currently write files outside the destination path where a project shall be generated or updated. This is possible when rendering a [generated directory structure](https://copier.readthedocs.io/en/stable/configuring/#generating-a-directory-structure) whose rendered path is either a relative parent path or an absolute path. Constructing such paths is possible using Copier's builtin `pathjoin` Jinja filter and its builtin `_copier_conf.sep` variable, which is the platform-native path separator. This way, a malicious template author can create a template that overwrites arbitrary files (according to the user's write permissions), e.g., to cause havoc.\n\n#### Write access via generated relative path\n\nReproducible example:\n\n```shell\necho \"foo\" > forbidden.txt\nmkdir src/\necho \"bar\" > \"src/{{ pathjoin('..', 'forbidden.txt') }}\"\nuvx copier copy src/ dst/\ncat forbidden.txt\n```\n\n#### Write access via generated absolute path\n\nReproducible example:\n\n- POSIX:\n\n    ```shell\n    # Assumption: The current working directory is `/tmp/test-copier-vulnerability/`\n    echo \"foo\" > forbidden.txt\n    mkdir src/\n    echo \"bar\" > \"src/{{ pathjoin(_copier_conf.sep, 'tmp', 'test-copier-vulnerability', 'forbidden.txt') }}\"\n    uvx --from copier python -O -m copier copy --overwrite src/ dst/\n    cat forbidden.txt\n    ```\n\n- Windows (PowerShell):\n\n    ```powershell\n    # Assumption: The current working directory is `C:\\Users\\<user>\\Temp\\test-copier-vulnerability`\n    echo \"foo\" > forbidden.txt\n    mkdir src\n    Set-Content -Path src\\copier.yml @'\n    drive:\n      type: str\n      default: \"C:\"\n      when: false\n    '@\n    echo \"bar\" > \"src\\{{ pathjoin(drive, 'Users', '<user>', 'Temp', 'test-copier-vulnerability', 'forbidden.txt') }}\"\n    uvx --from copier python -O -m copier copy --overwrite src dst\n    cat forbidden.txt\n    ```\n\nThis scenario is slightly less severe, as Copier has a few [assertions of the destination path being relative](https://github.com/copier-org/copier/blob/d106ea543fd26e1ac1b9a3dcef3e99cc70fdf57c/copier/_main.py#L747) which would typically be raised. But `python -O` (or `PYTHONOPTIMIZE=x`) removes asserts, so these guards may be ineffective. In addition, this scenario will prompt for overwrite confirmation or require the `--overwrite` flag for non-interactive mode; yet malicious file writes might go unnoticed.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:N/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "copier"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "7.1.0"
      }, {
        "fixed" : "9.9.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/copier-org/copier/security/advisories/GHSA-p7q8-grrj-3m8w"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-55214"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/copier-org/copier/commit/fdbc0167cc22780b497e4db176feaf6f024757d6"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/copier-org/copier"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-08-18T21:01:07Z",
    "nvd_published_at" : "2025-08-18T17:15:30Z"
  }
}