Remote Code Execution in Elasticsearch – CVE-2015-1427
Elasticsearch's Groovy scripting sandbox could be bypassed using Java reflection, allowing an unauthenticated attacker to execute arbitrary system commands on a publicly exposed instance.
jordan-wright.github.io
Published on jordan-wright.github.io
Elasticsearch (the “E” in ELK) is a full-text search engine that makes data aggregation and querying easy. It has an extensive JSON API that allows everything from searching to system management.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The Groovy sandbox's method blacklist and package whitelist could be bypassed by chaining .class and .forName() reflection calls to load restricted classes such as java.lang.Runtime.
Impact
An unauthenticated attacker could execute arbitrary commands on a publicly reachable Elasticsearch instance, and the author reports seeing such exploitation in the wild.
What the attacker needed
Elasticsearch exposed to the attacker; No authentication required; Version before 1.4.3
The fix
Upgrade Elasticsearch to version 1.4.3 or later, and avoid exposing the service publicly.
How it was found
- Send a search request containing a script field that uses reflection to load java.lang.Runtime.
- Observe that the response returns the java.lang.Runtime class, confirming the sandbox bypass.
- Combine this with the earlier script execution technique to run arbitrary system commands.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Elasticsearch is a search engine that lets users send small scripts to run on the server. The server tried to block dangerous commands with a sandbox, but a feature called reflection let attackers load and use restricted classes anyway. Because there was no login required, anyone who could reach the server could run their own commands on it.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.