{"id":"CVE-2026-23986","aliases":["CVE-2026-23986","GHSA-4fqp-r85r-hxqh","PYSEC-2026-1272"],"related":[],"kind":"vulnerability","state":"published","title":"Copier safe template has arbitrary filesystem write access via directory symlinks when _preserve_symlinks: true","summary":"Copier is a library and CLI app for rendering project templates. Prior to version 9.11.2, 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. Version 9.11.2 patches the issue.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Copier is a library and CLI app for rendering project templates. Prior to version 9.11.2, 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. Version 9.11.2 patches the issue.","source":"cvelist"},{"lang":"en","text":"### 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 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's write permissions), e.g., to cause havoc.\n\n> [!NOTE]\n>\n> At the time of writing, the exploit is non-deterministic, as Copier walks the template's 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\" > sensitive.txt\npopd\n\nmkdir src/\npushd src/\nln -s ../other other\necho \"overwritten\" > \"{{ pathjoin('other', 'sensitive.txt') }}.jinja\"\necho \"_preserve_symlinks: true\" > copier.yml\ntree .\n# .\n# ├── copier.yml\n# ├── other -> ../other\n# └── {{ pathjoin('other', 'sensitive.txt') }}.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","format":"markdown","source":"ghsa"},{"lang":"es","text":"Copier es una librería y aplicación CLI para renderizar plantillas de proyecto. Antes de la versión 9.11.2, Copier sugiere que es seguro generar un proyecto a partir de una plantilla segura, es decir, una que no utiliza características inseguras como extensiones Jinja personalizadas, lo que requeriría pasar la bandera '--UNSAFE,--trust'. Resulta que una plantilla segura puede actualmente escribir en directorios arbitrarios fuera de la ruta de destino utilizando un enlace simbólico de directorio junto con '_preserve_symlinks: true' y una estructura de directorio generada cuya ruta renderizada está dentro del directorio con enlace simbólico. De esta manera, un autor de plantilla malicioso puede crear una plantilla que sobrescribe archivos arbitrarios (según los permisos de escritura del usuario), por ejemplo, para causar estragos. La versión 9.11.2 corrige el problema.","source":"nvd"}],"published":"2026-01-21T22:19:29.000Z","modified":"2026-07-07T17:56:39.975Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":6.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":6.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H","score":7.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H","score":7.1,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:H","score":7.1,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"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"}],"cwes":["CWE-61"],"affected":[{"ranges":[{"version":"< 9.11.2","status":"affected"}],"vendor":"copier-org","product":"copier","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"9.11.2"}],"ecosystem":"PyPI","package":"copier","purl":"pkg:pypi/copier","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"9.11.2"}],"vendor":"copier-org","product":"copier","cpe":"cpe:2.3:a:copier-org:copier:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"9.11.2"}],"ecosystem":"PyPI","package":"copier","purl":"pkg:pypi/copier","source":"pysec"}],"references":[{"url":"https://github.com/copier-org/copier/security/advisories/GHSA-4fqp-r85r-hxqh","tags":["exploit","third-party-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/copier-org/copier/commit/b3a7b3772d17cf0e7a4481978188c9f536c8d8f6","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/copier-org/copier/releases/tag/v9.11.2","tags":["product","release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-23986","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/copier-org/copier","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/copier","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-4fqp-r85r-hxqh","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-01-22T15:10:50.987Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-23986","url":"https://www.cve.org/CVERecord?id=CVE-2026-23986","licence":"CVE Terms of Use","modified":"2026-01-22T16:49:26.426Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-4fqp-r85r-hxqh","url":"https://github.com/advisories/GHSA-4fqp-r85r-hxqh","licence":"CC-BY-4.0","modified":"2026-07-07T17:56:39.975Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-23986","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-23986","licence":"Public domain","modified":"2026-06-17T10:22:24.030Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-1272","url":"https://osv.dev/vulnerability/PYSEC-2026-1272","licence":"CC-BY-4.0","modified":"2026-07-07T17:47:12.903Z"}],"updatedAt":"2026-11-25T22:59:13.030Z","epss":{"score":0.0027,"percentile":0.20512,"date":"2026-12-01T12:00:22.000Z"}}