PT-2026-108628
Publicado
2026-10-08
·
Atualizado
2026-10-08
Descrição por
Pontuação
N/A
Não disponívelNão há classificações de severidade ou métricas disponíveis. Quando houver, atualizaremos as informações correspondentes na página.
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 bysave()uponreg.set(), or read viaload().- 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
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
- In
validate index path(): verifyindex pathis not a symlink and resolves withinpath. - 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
Encontrou algum problema na descrição? Tem algo a acrescentar? Fique à vontade para nos escrever 👾