Springboot框架actuator配置不当修复方案及验证详细

Springboot框架actuator配置不当修复方案及验证详细

1.判断是否使用了Springboot框架

方法一: 查看网页图标 如果是类似imgSpringBoot框架的默认图标

这样的图标则大概率是使用了该框架

方法二:在方法一如果不能完全确定时,可以在网页路径在输入错误路径导致网页报错

查看网页的报错界面,如果是如下界面则基本可以确定使用了SpringBoot框架

img

2.枚举actuator下的路径

在确定是SpringBoot框架后,枚举站点的一级、二级甚至三级目录,查看目录下面是否存在actuator执行端点路径

在application.properties配置文件中查看actuator的访问路径

如 设置management.context-path=/monitor

则访问访问ip:port/monitor/actuator

默认配置下 management.context-path=/

此时访问ip:port/actuator 暴露配置信息

img

根据actuator信息知道可以访问/actuator/health 和 /actuator/info

imgimg

Actuator模块下路径功能

img

漏洞修复方案

方案一

可以在application.properties配置文件修改配置

开启业务需求上必须的端口(建议全部禁用)
通过配置management.endpoint.<端点名称>.enabled为true/false来开启/禁用端口``

management.endpoints.enabled = false //禁用所有端口
management.endpoints.metrics.enabled = true   //开启metrics端点

img

通过配置management.endpoint.web.exposure.include=xxx 来暴露某个web端点

通过配置management.endpoint.web.exposure.exclude=xxx 来隐藏某个web端点

如:

暴露所有端点

management.endpoints.web.exposure.include=*

隐藏(不暴露)端点info

management.endpoints.web.exposure.exclude=info

隐藏(不暴露)端点env beans

management.endpoints.web.exposure.exclude=env,beans

方案二

引入安全依赖,增加验证环节

引入spring-boot-starter-security依赖

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
</dependency>

在application.properties中指定actuator的端口以及开启security功能,下图是程序启动时自动生成的字符串

img

management.port=8099
management.security.enabled=true
security.user.name=账号
security.user.password=密码(注意密码复杂度)

这样再访问actuator的时候就会弹出登陆框

验证方法

  1. 再次访问指定的路径,若未能查看到配置信息,则配置安全

总结

在使用Actuator时,不正确的使用或者一些不经意的疏忽,就会造成严重的信息泄露等安全隐患。在代码审计时如果是Springboot项目并且遇到actuator依赖,则有必要对安全依赖及配置进行复查。也可作为一条规则添加到黑盒扫描器中进一步把控。
安全的做法是一定要引入security依赖,打开安全限制并进行身份验证。同时设置单独的Actuator管理端口并配置不对外网开放。

posted @ 2021-07-10 15:06  cjz12138  阅读(2927)  评论(0编辑  收藏  举报