优选主流主机商
任何主机均需规范使用

elasticsearch未授权访问漏洞修复

1、漏洞简介

Elasticsearch是一款java编写的企业级搜索服务。越来越多的公司使用ELK作为日志分析,启动此服务默认会开放9200端口或者9300端口,可被非法操作数据。

2、漏洞检测

curl http://IP:PORT/_nodes#查看节点数据

http://IP:PORT/_nodes?prettify

http://IP:PORT/_cat/indices

http://IP:PORT/_plugin/head/

http://IP:PORT/_status

http://IP:PORT/_river/_search#查看数据库敏感信息

http://IP:PORT/_search?pretty

http://IP:PORT/zjftu/

http://IP:PORT/zjftu/_search?pretty

3、漏洞修复

访问控制策略,限制IP访问,绑定固定IP

在config/elasticsearch.yml中为9200端口设置认证等

4、设置安全认证的方式

1)修改elasticsearch.yml,然后重启服务

#允许head插件等访问的相关设置

http.cors.enable:true

http.cors.allow_origin:”*”

http.cors.allow_headers:Authorization,X-Requested-With,Content-length,Content-Type

http.cors.allow_credentials:ttrue

#是否启用es的安全设置,启用安全设置后es各节点、客户端的传输都会加密,并需要账号密码

xpack.security.enabled:true

#此项不可更改,当启用安全设置后,此项必须为true

xpack.security.transport.ssl.enabled:true

2)设置elasticsearch密码

usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive

因为需要设置 elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user 这些用户的密码,故这个过程比较漫长,耐心设置;

3)修改密码

curl -H “Content-Type:application/json” -XPOST -u elastic ‘http://127.0.0.1:9200/_xpack/security/user/elastic/_password’ -d ‘{“password”:”123456″}’

4)如果忘记密码怎么办?如何重置

1、修改elasticsearch.yml配置,将身份验证相关配置屏蔽掉;

2、重启ES,查看下索引,发现多了一个.security-7索引,将其删除

3、到此就回到ES没有设置密码的阶段了。

未经允许不得转载:搬瓦工中文网 » elasticsearch未授权访问漏洞修复