Springboot框架actuator配置不當修復方案及驗證詳細
1.判斷是否使用了Springboot框架
方法一: 查看網頁圖標 如果是類似SpringBoot框架的默認圖標
這樣的圖標則大概率是使用了該框架
方法二:在方法一如果不能完全確定時,可以在網頁路徑在輸入錯誤路徑導致網頁報錯
查看網頁的報錯界面,如果是如下界面則基本可以確定使用了SpringBoot框架
2.枚舉actuator下的路徑
在確定是SpringBoot框架后,枚舉站點的一級、二級甚至三級目錄,查看目錄下面是否存在actuator執行端點路徑
在application.properties配置文件中查看actuator的訪問路徑
如 設置management.context-path=/monitor
則訪問訪問ip:port/monitor/actuator
默認配置下 management.context-path=/
此時訪問ip:port/actuator 暴露配置信息
根據actuator信息知道可以訪問/actuator/health 和 /actuator/info
Actuator模塊下路徑功能
漏洞修復方案
方案一:
可以在application.properties配置文件修改配置
開啟業務需求上必須的端口(建議全部禁用)
通過配置management.endpoint.<端點名稱>.enabled為true/false來開啟/禁用端口``
management.endpoints.enabled = false //禁用所有端口
management.endpoints.metrics.enabled = true //開啟metrics端點
通過配置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功能,下圖是程序啟動時自動生成的字符串
management.port=8099
management.security.enabled=true
security.user.name=賬號
security.user.password=密碼(注意密碼復雜度)
這樣再訪問actuator的時候就會彈出登陸框
驗證方法
- 再次訪問指定的路徑,若未能查看到配置信息,則配置安全
總結
在使用Actuator時,不正確的使用或者一些不經意的疏忽,就會造成嚴重的信息泄露等安全隱患。在代碼審計時如果是Springboot項目並且遇到actuator依賴,則有必要對安全依賴及配置進行復查。也可作為一條規則添加到黑盒掃描器中進一步把控。
安全的做法是一定要引入security依賴,打開安全限制並進行身份驗證。同時設置單獨的Actuator管理端口並配置不對外網開放。