Copier `_external_data` allows path traversal and absolute-path local file read without unsafe mode
Date: 2026-04
Affected: pip/copier
Attack vector: path-traversal
Category: vulnerability-disclosure
Severity: Medium
CVE: CVE-2026-34730
CWE: CWE-22
CVSS: 5.5 (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:N/A:N)

### 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


Mitigations:

Architectural layers (MAESTRO):