问题场景:线上页面安全测试反馈存在SpringBoot Actuator未授权访问问题。简单说就是访问https://xxx.xx.x/actuator/env(xxx.xx.x,页面调用接口域名)时,会返回全部环境属性。
****风险分析:****Actuator 是 springboot 提供的用来对应用系统进行自省和监控的功能模块,借助于 Actuator 开发者可以很方便地对应用系统某些监控指标进行查看、统计等。在 Actuator 启用的情况下,如果没有做好相关权限控制,非法用户可通过访问默认的执行器端点(endpoints)来获取应用系统中的监控信息。
Actuator 相关信息可以自行检索了解,在查找解决方案时,发现主要有以下几种处理:
1.禁用/env接口
management:
endpoint:
env:
enabled: false
2.可以在配置文件中把暴露出的端点排除掉
#开启所有的端点访问(目前 health和info是默认开启的)
management.endpoints.web.exposure.include=*
#屏蔽掉health端点
management.endpoints.web.exposure.exclude=health
3.引入spring-boot-starter-security依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</de