Remote Code Execution in Elasticsearch – CVE-2015-1427
jordan-wright.github.io
jordan-wright.github.io
One feature of the _search API endpoint is to allow users to submit Groovy code in the search query itself. The server will then execute the code in a sandboxed environment, returning the result to the user. This way, the elasticsearch code can be used to execute… more code.
Quite a dangerous feature indeed. Thankfully, according to the documentation[0], this feature is disabled by default since v1.4.3. (Hindsight is 20/20, but this probably should have been the case from the get-go)
0. https://www.elastic.co/guide/en/elasticsearch/reference/curr...
In response to this, I made an open-source honeypot (in Go!) called Elastichoney. I recently released every single log I collected in nice JSON form:
http://jordan-wright.github.io/blog/2015/05/11/60-days-of-wa...
Let me know if you have any questions!
https://gist.github.com/jwpari/3369a537b422ecfa23f5
Use with:
nmap -T5 -p 9200 -Pn --script=+elasticsearch-cve-2015-1427 10.0.0.0/8I don't really understand why a project like this would default to having such vulnerable settings turned ON.
tl;dr: If you're doing sandboxing by blacklisting specific strings in your input, you're doing it wrong. Java actually has good sandboxing capabilities. Use them!
His conclusion says that using Groovy for scripting on the JVM comes at the price of security, and that the customizers in the Groovy distribution and those in the wild aren't enough to guarantee security of execution of scripts in the general case, but if you loosen some of the dynamic features of Groovy, you can work around those limitations through type checking extensions, though that solution isn't available in Groovy's core distro. He adds he'll have less time to work on Groovy, probably refering to how he and the other full-timer building Groovy had their funding pulled beginning the following week (end March 2015). There's now noone working fulltime building Groovy.
I swore I read something about attempting to break the JS sandbox but found nothing with my weak Googlefu.
Separately is escaping the sandbox due to a bug in the verification. JS is probably far easier to secure, since all the APIs are "safe" to call. That is, there isn't a huge JS stdlib that needs to be restricted. Like brainfuck-there's no way to make dangerous calls. Whereas Java has a huge stdlib that's accessible, so you're fighting an uphill battle to lock it down.
At the very least, limit the set of IPs that can connect to your server.