漏洞概述
1、Heapdump 端点泄露:
-
攻击者可以访问 Spring Boot 管理端点 /actuator/heapdump,从而获取应用程序的内存快照。
-
如果 Shiro 密钥或其他敏感信息存储在内存中,攻击者可以从 heapdump 文件中提取这些信息。
2、注入内存马:
- 攻击者可能利用已获取的 Shiro 密钥或其他敏感信息进一步注入内存马。
- 内存马是一种恶意程序,它可以驻留在内存中而不留下明显的痕迹,从而绕过传统的防御机制。
- 攻击者可以利用内存马维持持久的访问权限,并执行恶意操作。
修复方案
禁用或限制 heapdump 端点:
- 在 Spring Boot 应用的配置文件中禁用 heapdump 端点:
Properties
1 management.endpoints.web.exposure.include=
或者
Yaml
1 management:
2 endpoints:
3 web:
4 exposure:
5 include: []
- 如果需要保留 heapdump 功能,限制其访问权限:
Properties
1 management.endpoints.web.exposure.include=heapdump
2 management.endpoints.web.authentication.mode=BASIC
3 management.endpoints.web.authentication.users.admin=secret
或者
Yaml
1 management:
2 endpoints:
3 web:
4 exposure:
5 include: heapdump
6 authentication:
7 mode: BASIC
8 users:
9 admin: $2a$10$PmZlDzvGKt3H6L6qUjR5nOuXcUwQzJp1j8oVhWg6Zs05i3r8Ff9Y2
2、使用环境变量存储密钥:
- 不要将 Shiro 密钥硬编码在代码或配置文件中,而是使用环境变量来存储这些密钥。
3、使用外部密钥管理系统:
- 考虑使用像 HashiCorp Vault 这样的密钥管理系统来管理应用程序的密钥。
4、加强日志记录和审计:
- 增加对敏感操作的日志记录,以便能够追踪任何可疑活动。
5、定期轮换密钥:
- 定期更换 Shiro 密钥,以降低密钥长期泄露的风险。
6、更新依赖库:
- 确保所有依赖库都是最新版本,并且没有已知的安全漏洞。