{"id":"CVE-2026-107716","aliases":["CVE-2026-107716","GHSA-556j-vv39-8rqv","PYSEC-2026-4201"],"related":[],"kind":"vulnerability","state":"published","title":"Banks: Symlink traversal and arbitrary file disclosure/overwrite in DirectoryPromptRegistry","summary":"Banks generates meaningful LLM prompts using a simple template language. Prior to 2.5.1, Banks DirectoryPromptRegistry does not reject symbolic links for index.json or discovered and existing .jinja prompt files. In an application where untrusted users can influence a prompt directory, DirectoryPromptRegistry._scan() and DirectoryPromptRegistry.get() can follow a link outside the registry root and disclose a file, while DirectoryPromptRegistry.set(), DirectoryPromptRegistry._save(), and DirectoryPromptRegistry._load() can read or overwrite an external link target. The issue requires attacker influence over the registry directory or its extracted contents. This issue is fixed in version 2.5.1.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Banks generates meaningful LLM prompts using a simple template language. Prior to 2.5.1, Banks DirectoryPromptRegistry does not reject symbolic links for index.json or discovered and existing .jinja prompt files. In an application where untrusted users can influence a prompt directory, DirectoryPromptRegistry._scan() and DirectoryPromptRegistry.get() can follow a link outside the registry root and disclose a file, while DirectoryPromptRegistry.set(), DirectoryPromptRegistry._save(), and DirectoryPromptRegistry._load() can read or overwrite an external link target. The issue requires attacker influence over the registry directory or its extracted contents. This issue is fixed in version 2.5.1.","source":"cvelist"},{"lang":"en","text":"### Summary\nIn `banks.registries.DirectoryPromptRegistry`, prompt file paths and the index file (`index.json`) do not refuse symbolic links. When a prompt directory contains or accepts untrusted files (e.g. unpacked archives, shared repositories, or multi-tenant folders), symbolic links pointing outside the registry root can be used to disclose arbitrary files via `_scan()` / `get()` or overwrite arbitrary files via `set()` / `_save()`.\n\n### Details\nFollowing PR #77, `DirectoryPromptRegistry` validates path resolution for prompt names. However:\n1. `self._index_path` (`index.json`) is not checked for symbolic links. A symlink pointing to an external target (e.g. a configuration file) will be overwritten by `_save()` upon `reg.set()`, or read via `_load()`.\n2. In `_scan()`, discovered `.jinja` files are opened and indexed without checking if `path.is_symlink()` or if the resolved path escapes the registry root. A symlink pointing to a sensitive file outside the root is read and indexed.\n3. In `set()`, `prompt_file.write_text(...)` is called without checking if `prompt_file` is an existing symbolic link pointing outside the root.\n\n### Impact\nArbitrary file disclosure (CWE-59 / CWE-200) and arbitrary file overwrite (CWE-59) in applications where prompt directories can be influenced by untrusted users or extracted from archives.\n\n### Proof of Concept\n```python\nimport os\nfrom pathlib import Path\nfrom banks.registries.directory import DirectoryPromptRegistry, DEFAULT_INDEX_NAME\nfrom banks.prompt import Prompt\n\n# Disclose external file via symlink in prompt directory\nreg_dir = Path(\"/tmp/registry\")\nreg_dir.mkdir(exist_ok=True)\nsecret = Path(\"/tmp/secret.txt\")\nsecret.write_text(\"SECRET_API_TOKEN\")\n\nos.symlink(secret, reg_dir / \"leak.0.jinja\")\nreg = DirectoryPromptRegistry(reg_dir, force_reindex=True)\nprint(\"Disclosed content:\", reg.get(name=\"leak\", version=\"0\").raw)\n\n# Overwrite external file via symlink index\ntarget = Path(\"/tmp/target.conf\")\ntarget.write_text(\"ORIGINAL\")\n(reg_dir / DEFAULT_INDEX_NAME).unlink(missing_ok=True)\nos.symlink(target, reg_dir / DEFAULT_INDEX_NAME)\nreg.set(prompt=Prompt(\"pwn\", name=\"test\", version=\"1\"))\nprint(\"Target overwritten:\", target.read_text())\n```\n\n### Remediation\n1. In `_validate_index_path()`: verify `_index_path` is not a symlink and resolves within `_path`.\n2. In `_scan()`: reject `path.is_symlink()` and check `path.resolve().is_relative_to(root)`.\n3. In `set()`: reject existing symbolic links before writing.\n\nA tested fix and regression tests have been prepared and pushed to:\nhttps://github.com/jankesec/banks/tree/fix-directory-registry-symlinks-and-nesting","format":"markdown","source":"ghsa"}],"published":"2026-10-08T21:33:13.391Z","modified":"2026-10-15T14:55:55.950Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N","score":7.3,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:L/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N","score":7.3,"rating":"HIGH"},{"scorer":"GitHub","scheme":"rating","rating":"MEDIUM"}],"cwes":["CWE-22","CWE-59"],"affected":[{"ranges":[{"version":"< 2.5.1","status":"affected"}],"vendor":"masci","product":"banks","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.5.1"}],"ecosystem":"PyPI","package":"banks","purl":"pkg:pypi/banks","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.5.1"}],"ecosystem":"PyPI","package":"banks","purl":"pkg:pypi/banks","source":"pysec"}],"references":[{"url":"https://github.com/masci/banks/security/advisories/GHSA-556j-vv39-8rqv","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/masci/banks/pull/79","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/masci/banks/commit/23ed13e50b4e217693fa5f9c30943fac8a41582f","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/masci/banks/releases/tag/v2.5.1","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/masci/banks","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/banks","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-556j-vv39-8rqv","tags":["advisory"],"sources":["pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-107716","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-10-09T14:54:57.852Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-107716","url":"https://www.cve.org/CVERecord?id=CVE-2026-107716","licence":"CVE Terms of Use","modified":"2026-10-09T15:13:19.781Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-556j-vv39-8rqv","url":"https://github.com/advisories/GHSA-556j-vv39-8rqv","licence":"CC-BY-4.0","modified":"2026-10-15T14:55:55.950Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-107716","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-107716","licence":"Public domain","modified":"2026-10-09T16:17:23.310Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-4201","url":"https://osv.dev/vulnerability/PYSEC-2026-4201","licence":"CC-BY-4.0","modified":"2026-10-15T14:45:06.048Z"}],"updatedAt":"2026-11-25T22:59:43.239Z","epss":{"score":0.00134,"percentile":0.03136,"date":"2026-12-01T12:00:22.000Z"}}