CVE-2026-34730: Copier `_external_data` allows path traversal and absolute-path local file read without unsafe mode
Summary Copier's externaldata 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.
Published Apr 1, 2026 · Updated Apr 6, 2026
Affected packages
copier
- Ecosystem
- PyPI
- Affected
- <= 9.14.0
- Fixed in
- 9.14.1
- Check
pip show copier
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
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:
- A template defines
_external_data - Copier renders the configured path string
- Copier calls
load_answersfile_data(dst_path, rendered_path, warn_on_missing=True) load_answersfile_data()opensPath(dst_path, answers_file)directly- Parsed YAML becomes available as
_external_data.<name>during rendering
Relevant code:
The sink is:
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 . _external_data does not apply an equivalent containment check.
The public documentation describes _external_data values as relative paths "from the subproject destination" in , 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 ../
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.txtExpected output:
topsecretPoC 2: _external_data reads an absolute path
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.txtExpected output:
abssecretImpact
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
Credited to evipepota, sisp.
References
- https://github.com/copier-org/copier/security/advisories/GHSA-hgjq-p8cr-gg4h
- https://nvd.nist.gov/vuln/detail/CVE-2026-34730
- https://github.com/copier-org/copier/commit/5413062eb17b73dc885f5e645cdc161e69ef641b
- https://github.com/copier-org/copier/releases/tag/v9.14.1
- https://github.com/advisories/GHSA-hgjq-p8cr-gg4h
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More PyPI vulnerabilities
All PyPI entriesCVE-2026-53951
Copier has a trust-prefix bypass via path traversal that runs tasks unprompted
high8.8Aug 19, 2026CVE-2026-34726
Copier `_subdirectory` allows template root escape via parent-directory traversal
medium4.4Apr 1, 2026CVE-2026-23968
Copier safe template has arbitrary filesystem read access via symlinks when _preserve_symlinks: false
medium5.5Jan 21, 2026CVE-2026-23986
Copier safe template has arbitrary filesystem write access via directory symlinks when _preserve_symlinks: true
medium7.1Jan 21, 2026CVE-2025-55201
Copier's safe template has arbitrary filesystem read/write access
high8.5Aug 18, 2025CVE-2025-55214
Copier's safe template has filesystem write access outside destination path
medium6.9Aug 18, 2025
