Kestrel
대시보드로 돌아가기
CVE-2026-65915MEDIUM· 6.5MITRENVDGHSA대응게시일: 2026. 08. 22.수정일: 2026. 09. 08.

NLTK: FileSystemPathPointer.open() sandbox check is dead code — arbitrary file read via file:// protocol

위협 신호 · CVSS · EPSS · KEV

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

이론적 심각도 점수

EPSS
0.4%상위 70.9%

30일 내 악용 확률 예측

KEV
미등재

실측 악용 기록 없음

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

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

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

CVSS 벡터 · 메트릭

악용 경로
공격 벡터네트워크
공격 복잡도낮음
필요 권한낮음
사용자 상호작용불필요
범위불변
영향
기밀성 영향높음
무결성 영향없음
가용성 영향없음
버전별 점수
CVSS 3.16.5MODERATE
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N

상세 설명

Summary

There's a logic bug in FileSystemPathPointer.open() inside nltk/data.py
that makes the sandbox check permanently inert. The guard condition is always
False — meaning any file the process can read is accessible by passing a
file:// URL to nltk.data.load().


Details

In nltk/data.py, FileSystemPathPointer.open() was patched at some point
with a comment saying "SECURITY PATCH ENFORCING SANDBOX", but the check
doesn't work:

python
1def open(self, encoding=None):
2 path = os.path.normpath(self._path)
3
4 # Block raw absolute reads such as "/" "C:\\Windows" etc.
5 if os.path.isabs(path) and path != os.path.normpath(self._path):
6 raise ValueError(f"Direct absolute file access blocked: {path}")
7
8 stream = open(self._path, "rb")

path is set to os.path.normpath(self._path) on line 1, then compared
against os.path.normpath(self._path) again in the condition. They are
always equal. The ValueError never fires.

On top of that, __init__ already calls os.path.abspath() before storing
self._path, so it's normalized before open() is even called. Running
normpath on it again changes nothing.

The stream = open(self._path, "rb") line is always reached regardless of
what path was passed in.


PoC

Tested on Python 3.11, NLTK 3.9.1, Ubuntu 22.04.

python
1import nltk
2from nltk.data import FileSystemPathPointer
3
4# direct construction
5ptr = FileSystemPathPointer("/etc/passwd")
6with ptr.open() as f:
7 print(f.read(300))
8
9# via load() using file:// URL
10data = nltk.data.load("file:///etc/passwd", format="raw")
11print(data[:300])

Both print file contents. No exception is raised.


Impact

Any app that lets users influence the string passed to nltk.data.load() or
nltk.data.find() is exposed — web APIs, notebook servers, multi-tenant
pipelines. An attacker can read any file the process user has access to:
/etc/passwd, .env files, private keys, ~/.aws/credentials, etc.

Suggested Fix

File: nltk/data.pyFileSystemPathPointer.open() (lines 378–390)

What's wrong

Line 387 compares normpath(self._path) against itself — always equal,
so the ValueError never fires. The check is dead code.
__init__ already calls abspath() on construction, so re-running
normpath inside open() changes nothing either.


Fix

Validate against the actual list of permitted data directories instead:

python
1def open(self, encoding=None):
2 import nltk.data as _d
3 allowed = [os.path.abspath(p) for p in _d.path if p]
4 if allowed and not any(
5 os.path.commonpath([self._path, r]) == r for r in allowed
6 ):
7 raise ValueError(
8 f"Access outside nltk_data blocked: {self._path!r}"
9 )
10 stream = open(self._path, "rb")
11 if encoding is not None:
12 stream = SeekableUnicodeStreamReader(stream, encoding)
13 return stream

Why commonpath not startswith

startswith is bypassable by a path that shares a prefix:

text
1/tmp/nltk_data_evil".startswith("/tmp/nltk_data") → True ✗
2commonpath(["/tmp/nltk_data_evil", "/tmp/nltk_data"]) → "/tmp"

Diff

text
1- path = os.path.normpath(self._path)
2- if os.path.isabs(path) and path != os.path.normpath(self._path):
3- raise ValueError(f"Direct absolute file access blocked: {path}")
4-
5+ import nltk.data as _d
6+ allowed = [os.path.abspath(p) for p in _d.path if p]
7+ if allowed and not any(
8+ os.path.commonpath([self._path, r]) == r for r in allowed
9+ ):
10+ raise ValueError(f"Access outside nltk_data blocked: {self._path!r}")
11 stream = open(self._path, "rb")

AI 심층 분석

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