CVE-2026-107716: Banks Symlink Traversal And Arbitrary File Vulnerability

MODERATE
Advisory Identifier: GHSA-556j-vv39-8rqv
CWE-59 CWE-22
Published
Advisory Summary

CVE-2026-107716 is a MODERATE symlink traversal and arbitrary file vulnerability (CWE-59: Improper Link Resolution Before File Access ('Link Following')) affecting Banks libraries in the PyPI ecosystem. The issue involves symlink traversal and arbitrary file disclosure/overwrite in directorypromptregistry. Remediation is available by upgrading affected packages to version 2.5.1.

CVE-2026-107716 at a Glance

CVE Identifier CVE-2026-107716
GHSA Identifier GHSA-556j-vv39-8rqv
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-59: Improper Link Resolution Before File Access ('Link Following')
Affected Product Banks
Package Ecosystem PyPI
Published Date
Last Updated

How to Fix CVE-2026-107716

To remediate this vulnerability, upgrade all affected Banks dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

banks fixed: 2.5.1
pip install banks>=2.5.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show banks

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-107716, inspect your installed packages using pip:

pip show banks

Analyze the terminal output to locate any version of Banks in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.5.1), your application is affected.

Note: The pip show banks command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following'), where the product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource. In Banks, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary In `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()`. ### Details Following PR #77, `DirectoryPromptRegistry` validates path resolution for prompt names. However: 1. `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()`. 2. 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. 3. In `set()`, `prompt_file.write_text(...)` is called without checking if `prompt_file` is an existing symbolic link pointing outside the root. ### Impact Arbitrary 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. ### Proof of Concept ```python import os from pathlib import Path from banks.registries.directory import DirectoryPromptRegistry, DEFAULT_INDEX_NAME from banks.prompt import Prompt # Disclose external file via symlink in prompt directory reg_dir = Path("/tmp/registry") reg_dir.mkdir(exist_ok=True) secret = Path("/tmp/secret.txt") secret.write_text("SECRET_API_TOKEN") os.symlink(secret, reg_dir / "leak.0.jinja") reg = DirectoryPromptRegistry(reg_dir, force_reindex=True) print("Disclosed content:", reg.get(name="leak", version="0").raw) # Overwrite external file via symlink index target = Path("/tmp/target.conf") target.write_text("ORIGINAL") (reg_dir / DEFAULT_INDEX_NAME).unlink(missing_ok=True) os.symlink(target, reg_dir / DEFAULT_INDEX_NAME) reg.set(prompt=Prompt("pwn", name="test", version="1")) print("Target overwritten:", target.read_text()) ``` ### Remediation 1. In `_validate_index_path()`: verify `_index_path` is not a symlink and resolves within `_path`. 2. In `_scan()`: reject `path.is_symlink()` and check `path.resolve().is_relative_to(root)`. 3. In `set()`: reject existing symbolic links before writing. A tested fix and regression tests have been prepared and pushed to: https://github.com/jankesec/banks/tree/fix-directory-registry-symlinks-and-nesting

CVE-2026-107716 Affected Banks Versions

1 component(s)
Fixed Versions:
2.5.1
Product / Package Ecosystem Affected Versions Fixed Version
banks
PyPI
< 2.5.1
2.5.1

References

Frequently Asked Questions

What is CVE-2026-107716?
CVE-2026-107716 is a security vulnerability in Banks involving Symlink traversal and arbitrary file disclosure/overwrite in DirectoryPromptRegistry under CWE-59: Improper Link Resolution Before File Access ('Link Following').
Which Banks versions are affected?
Affected versions include releases prior to 2.5.1 across affected packages: banks.
What version fixes CVE-2026-107716?
Upgrading to 2.5.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is banks affected?
Yes, banks is affected in releases prior to 2.5.1. Upgrade your dependency to 2.5.1 or later.
What CWE is associated with CVE-2026-107716?
CVE-2026-107716 is classified under CWE-59: Improper Link Resolution Before File Access ('Link Following') (The product attempts to access a file based on the filename, but it does not properly prevent that filename from identifying a link or shortcut that resolves to an unintended resource.).
How can I check PyPI dependencies for CVE-2026-107716?
Run the dependency tree command: 'pip show banks'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-556j-vv39-8rqv",
  "modified" : "2026-10-08T22:10:07Z",
  "published" : "2026-10-08T22:10:07Z",
  "aliases" : [ "CVE-2026-107716" ],
  "summary" : "Banks: Symlink traversal and arbitrary file disclosure/overwrite in DirectoryPromptRegistry",
  "details" : "### 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",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "banks"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.5.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.5.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/masci/banks/security/advisories/GHSA-556j-vv39-8rqv"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/masci/banks/pull/79"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/masci/banks/commit/23ed13e50b4e217693fa5f9c30943fac8a41582f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/masci/banks"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/masci/banks/releases/tag/v2.5.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-59" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-10-08T22:10:07Z",
    "nvd_published_at" : null
  }
}