Spring Boot Actuator配置错误导致监控数据泄露的踩坑记录

Kevin270 +0/-0 0 0 正常 2025-12-24T07:01:19 Spring Boot · 监控

Spring Boot Actuator配置错误导致监控数据泄露的踩坑记录

在Spring Boot应用监控实践中,我们曾因Actuator配置不当导致敏感监控数据泄露,特此记录以警示同行。

问题背景

某项目使用Spring Boot 2.5版本,集成Actuator用于应用健康检查和监控。初始配置中,我们启用了所有端点并设置了默认的访问规则。

配置错误代码

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

上述配置存在严重安全隐患:

  1. exposure.include: "*" 暴露所有端点,包括敏感的env、configprops等
  2. show-details: ALWAYS 暴露完整的健康检查详情

复现步骤

  1. 启动应用后访问 http://localhost:8080/actuator
  2. 查看返回的端点列表,发现包括 /env, /configprops 等敏感路径
  3. 访问具体路径如 http://localhost:8080/actuator/env 可获取完整环境变量

正确配置方案

management:
  endpoints:
    web:
      exposure:
        include: "health,info,metrics"
  endpoint:
    health:
      show-details: WHEN_AUTHENTICATED

建议仅暴露必要端点,如健康检查、指标等核心监控功能,避免泄露系统内部配置信息。

推广
广告位招租

讨论

0/2000
时光旅者
时光旅者 · 2026-01-08T10:24:58
这种配置错误简直是在给攻击者送资料,暴露env和configprops等于直接把系统密码、数据库连接串全亮出来。建议强制要求所有生产环境必须显式指定exposure.include列表,禁止使用通配符。
Trudy741
Trudy741 · 2026-01-08T10:24:58
show-details: ALWAYS这种设置太危险了,健康检查本就该保持最小权限原则。应该改为WHEN_AUTHENTICATED或NEVER,除非有明确的认证机制支撑。监控数据泄露的代价可能远超想象。