prometheus涉及pprof go信息泄露漏洞整改
作者:mmseoamin日期:2023-12-18

Prometheus涉及pprof go信息泄露漏洞整改

本文记录一下对系统渗透测试后反馈Prometheus涉及pprof go信息泄露,验证方法为http://ip:port/debug/pprof。为防止未经授权用户访问,现决定在Prometheus层面使用basic_auth加密整改。

环境配置

软件版本
KylinV10
Docker20.10.22
Prometheus2.19.0

1.生成basic_auth密钥

安装工具包并生成加密后密码

#安装工具包
yum install -y httpd-tools
#生成加密密码
htpasswd -nBC 12 '' | tr -d ':\n'
New password:               # 这里设置密码为Prometheus,实际使用请按照自己的集群需求定义密码
Re-type new password:
#生成的密码信息
y$SiMWc.Avsx4BE59PT88GcefVkJGBYduzMP5kXeV2EyDxgKvODGhBW

2.将密钥文件写入config.yml文件内

新建配置文件(暂时不使用TLS,使用TLS加密后Grafana获取不到数据,还需修改数据源配置)

cat > /usr/prometheus/config.yml< 

3.修改prometheus配置

新增basic_auth配置

scrape_configs:
  - job_name: 'prometheus'
    basic_auth:
      username: admin
      password: prometheus
    static_configs:
    - targets: ['prometheus:9090']

4.启动服务

4.1 service模式

修改/usr/lib/systemd/system/prometheus.service文件,在ExecStart后面追加-web.config.file=/usr/prometheus/config.yml

4.2 docker模式

修改镜像版本(≥2.40),在服务启动脚本命令内增加 --web.config.file配置

docker run -d --restart=unless-stopped --name=prometheus -p 9090:9090 -v /usr/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml -v /usr/prometheus/config.yml:/etc/prometheus/config.yml prom/prometheus:v2.24.0 --config.file=/etc/prometheus/prometheus.yml --web.config.file=/etc/prometheus/config.yml

5.访问测试

返回Unauthorized即整改完成

[root@localhost ~]# curl http://127.0.0.1:9090/debug/pprof/
Unauthorized