针对 Aiohttp <= 3.9.1 中 LFI/路径遍历漏洞的概念验证
[!IMPORTANT] 此脚本仅供教育用途。
任何非法使用均严格禁止。
$ git clone https://github.com/wizarddos/CVE-2024-23334
$ cd CVE-2024-23334
$ python3 exploit.py -u [url] -f [file] -d [static directory]
[!Note] 记得使 URL 和静态目录中的斜杠匹配——如果你输入
http://127.0.0.1/,那么目录不要带斜杠(例如static),反之亦然(URL 不带斜杠,目录带斜杠)。
漏洞本身源于 aiohttp 处理静态资源请求的方式
如果我们编写如下代码
app.router.add_routes([
web.static("/static", "static/", follow_symlinks=True)
])
follow_symlinks=True 使其容易受到 LFI 攻击。
要使用静态资源,你需要指定其根目录
follow_symlinks 选项告诉 aiohttp 跟随根目录外的符号链接,但并未检查链接本身是否位于根目录中。
因此,即使所述的“符号链接”根本不是链接,aiohttp 也会读取该文件并返回其内容
来源 https://github.com/aio-libs/aiohttp/security/advisories/GHSA-5h86-8mv2-jq9f