CVE-2026-34730: Copier Path Traversal Vulnerability

MODERATE
Advisory Identifier: GHSA-hgjq-p8cr-gg4h
CVSS 5.5
CWE-22
Published
Advisory Summary

CVE-2026-34730 is a MODERATE (CVSS 5.5) path traversal 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 `_external_data` allows path traversal and absolute-path local file read without unsafe mode. Remediation is available by upgrading affected packages to version 9.14.1.

CVE-2026-34730 at a Glance

CVE Identifier CVE-2026-34730
GHSA Identifier GHSA-hgjq-p8cr-gg4h
Severity MODERATE
CVSS v3.1 Base Score 5.5
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

Security Impact

CVSS: 5.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity None (I:N)
Availability None (A:N)

How to Fix CVE-2026-34730

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.14.1
pip install copier>=9.14.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-2026-34730, 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.14.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

### Summary Copier's `_external_data` feature allows a template to load YAML files using template-controlled paths. The documentation describes these values as relative paths from the subproject destination, so relative paths themselves appear to be part of the intended feature model. However, the current implementation also allows destination-external reads, including: - Parent-directory paths such as `../secret.yml` - Absolute paths such as `/tmp/secret.yml` and then exposes the parsed contents in rendered output. This is possible without `--UNSAFE`, which makes the behavior potentially dangerous when Copier is run against untrusted templates. I am not certain this is unintended behavior, but it is security-sensitive and appears important to clarify. ### Details The relevant flow is: 1. A template defines `_external_data` 2. Copier renders the configured path string 3. Copier calls `load_answersfile_data(dst_path, rendered_path, warn_on_missing=True)` 4. `load_answersfile_data()` opens `Path(dst_path, answers_file)` directly 5. Parsed YAML becomes available as `_external_data.<name>` during rendering Relevant code: - <https://github.com/copier-org/copier/blob/7aa7021bd73797c982492bac3535515d4484fdb7/copier/_main.py#L329-L332> - <https://github.com/copier-org/copier/blob/7aa7021bd73797c982492bac3535515d4484fdb7/copier/_user_data.py#L584-L592> The sink is: ```python with Path(dst_path, answers_file).open("rb") as fd: return yaml.safe_load(fd) ``` There is no containment check to ensure the resulting path stays inside the subproject destination. This is notable because Copier already blocks other destination-escape paths. Normal render-path traversal outside the destination is expected to raise `ForbiddenPathError`, and that behavior is explicitly covered by existing tests in <https://github.com/copier-org/copier/blob/7aa7021bd73797c982492bac3535515d4484fdb7/tests/test_copy.py#L1289-L1332>. `_external_data` does not apply an equivalent containment check. The public documentation describes `_external_data` values as relative paths "from the subproject destination" in <https://github.com/copier-org/copier/blob/7aa7021bd73797c982492bac3535515d4484fdb7/docs/configuring.md#L944-L1005>, with examples using `.copier-answers.yml` and `.secrets.yaml`. That clearly supports relative-path usage, but it does not clearly communicate that a template may escape the destination with `../...` or read arbitrary absolute paths. Because this behavior also works without `--UNSAFE`, it seems worth clarifying whether destination-external reads are intended, and if so, whether they should be documented as security-sensitive behavior. ### PoC #### PoC 1: `_external_data` reads outside the destination with `../` ```sh mkdir src dst echo 'token: topsecret' > secret.yml printf '%s\n' '_external_data:' ' secret: ../secret.yml' > src/copier.yml printf '%s\n' '{{ _external_data.secret.token }}' > src/leak.txt.jinja copier copy --overwrite src dst cat dst/leak.txt ``` Expected output: ```text topsecret ``` #### PoC 2: `_external_data` reads an absolute path ```sh mkdir abs-src abs-dst echo 'token: abssecret' > absolute-secret.yml printf '%s\n' '_external_data:' " secret: $(pwd)/absolute-secret.yml" > abs-src/copier.yml printf '%s\n' '{{ _external_data.secret.token }}' > abs-src/leak.txt.jinja copier copy --overwrite abs-src abs-dst cat abs-dst/leak.txt ``` Expected output: ```text abssecret ``` ### Impact If untrusted templates are in scope, a malicious template can read attacker-chosen YAML-parseable local files that are accessible to the user running Copier and expose their contents in rendered output. Practical impact: - Destination-external local file read - Disclosure of YAML/JSON/plain-text-like secrets if they parse successfully under `yaml.safe_load` - Possible without `--UNSAFE`

CVE-2026-34730 Affected Copier Versions

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

References

Frequently Asked Questions

What is CVE-2026-34730?
CVE-2026-34730 is a security vulnerability in Copier involving Copier `_external_data` allows path traversal and absolute-path local file read without unsafe mode 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.14.1 across affected packages: copier.
What version fixes CVE-2026-34730?
Upgrading to 9.14.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.14.1. Upgrade your dependency to 9.14.1 or later.
What is the CVSS score of CVE-2026-34730?
CVE-2026-34730 has a CVSS v3.1 base score of 5.5 (MODERATE) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N.
What CWE is associated with CVE-2026-34730?
CVE-2026-34730 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-2026-34730?
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-hgjq-p8cr-gg4h",
  "modified" : "2026-04-06T17:32:36Z",
  "published" : "2026-04-01T22:38:39Z",
  "aliases" : [ "CVE-2026-34730" ],
  "summary" : "Copier `_external_data` allows path traversal and absolute-path local file read without unsafe mode",
  "details" : "### Summary\n\nCopier's `_external_data` feature allows a template to load YAML files using template-controlled paths. The documentation describes these values as relative paths from the subproject destination, so relative paths themselves appear to be part of the intended feature model.\n\nHowever, the current implementation also allows destination-external reads, including:\n\n- Parent-directory paths such as `../secret.yml`\n- Absolute paths such as `/tmp/secret.yml`\n\nand then exposes the parsed contents in rendered output.\n\nThis is possible without `--UNSAFE`, which makes the behavior potentially dangerous when Copier is run against untrusted templates. I am not certain this is unintended behavior, but it is security-sensitive and appears important to clarify.\n\n### Details\n\nThe relevant flow is:\n\n1. A template defines `_external_data`\n2. Copier renders the configured path string\n3. Copier calls `load_answersfile_data(dst_path, rendered_path, warn_on_missing=True)`\n4. `load_answersfile_data()` opens `Path(dst_path, answers_file)` directly\n5. Parsed YAML becomes available as `_external_data.<name>` during rendering\n\nRelevant code:\n\n- <https://github.com/copier-org/copier/blob/7aa7021bd73797c982492bac3535515d4484fdb7/copier/_main.py#L329-L332>\n- <https://github.com/copier-org/copier/blob/7aa7021bd73797c982492bac3535515d4484fdb7/copier/_user_data.py#L584-L592>\n\nThe sink is:\n\n```python\nwith Path(dst_path, answers_file).open(\"rb\") as fd:\n    return yaml.safe_load(fd)\n```\n\nThere is no containment check to ensure the resulting path stays inside the subproject destination.\n\nThis is notable because Copier already blocks other destination-escape paths. Normal render-path traversal outside the destination is expected to raise `ForbiddenPathError`, and that behavior is explicitly covered by existing tests in <https://github.com/copier-org/copier/blob/7aa7021bd73797c982492bac3535515d4484fdb7/tests/test_copy.py#L1289-L1332>. `_external_data` does not apply an equivalent containment check.\n\nThe public documentation describes `_external_data` values as relative paths \"from the subproject destination\" in <https://github.com/copier-org/copier/blob/7aa7021bd73797c982492bac3535515d4484fdb7/docs/configuring.md#L944-L1005>, with examples using `.copier-answers.yml` and `.secrets.yaml`. That clearly supports relative-path usage, but it does not clearly communicate that a template may escape the destination with `../...` or read arbitrary absolute paths. Because this behavior also works without `--UNSAFE`, it seems worth clarifying whether destination-external reads are intended, and if so, whether they should be documented as security-sensitive behavior.\n\n### PoC\n\n#### PoC 1: `_external_data` reads outside the destination with `../`\n\n```sh\nmkdir src dst\necho 'token: topsecret' > secret.yml\n\nprintf '%s\\n' '_external_data:' '  secret: ../secret.yml' > src/copier.yml\nprintf '%s\\n' '{{ _external_data.secret.token }}' > src/leak.txt.jinja\n\ncopier copy --overwrite src dst\ncat dst/leak.txt\n```\n\nExpected output:\n\n```text\ntopsecret\n```\n\n#### PoC 2: `_external_data` reads an absolute path\n\n```sh\nmkdir abs-src abs-dst\necho 'token: abssecret' > absolute-secret.yml\n\nprintf '%s\\n' '_external_data:' \"  secret: $(pwd)/absolute-secret.yml\" > abs-src/copier.yml\nprintf '%s\\n' '{{ _external_data.secret.token }}' > abs-src/leak.txt.jinja\n\ncopier copy --overwrite abs-src abs-dst\ncat abs-dst/leak.txt\n```\n\nExpected output:\n\n```text\nabssecret\n```\n\n### Impact\n\nIf untrusted templates are in scope, a malicious template can read attacker-chosen YAML-parseable local files that are accessible to the user running Copier and expose their contents in rendered output.\n\nPractical impact:\n\n- Destination-external local file read\n- Disclosure of YAML/JSON/plain-text-like secrets if they parse successfully under `yaml.safe_load`\n- Possible without `--UNSAFE`",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "copier"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "9.14.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 9.14.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/copier-org/copier/security/advisories/GHSA-hgjq-p8cr-gg4h"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-34730"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/copier-org/copier/commit/5413062eb17b73dc885f5e645cdc161e69ef641b"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/copier-org/copier"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/copier-org/copier/releases/tag/v9.14.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-01T22:38:39Z",
    "nvd_published_at" : "2026-04-02T19:21:32Z"
  }
}