# End to end encryption public key is not properly verified on Desktop and Android

Nextcloud Desktop/Android E2EE clients fail to verify that a newly generated private key matches the server-stored public key, letting a malicious admin substitute their own key and decrypt uploaded data.

- Payout: $1,500
- Severity: medium
- Program: Nextcloud
- Found by: rtod
- Disclosed: 2021-09-23
- Write-up quality: 6/10
- Original: https://hackerone.com/reports/1189162
- Library page: https://bugbountylibrary.com/r/h1%3A1189162
- Tags: area:mobile domain:desktop domain:mobile impact:data-leak impact:integrity kind:bounty platform:hackerone sev:medium tech:android technique:source-review vuln:crypto vuln:misconfiguration

**Target:** Nextcloud end-to-end encryption client (Desktop, Android) key setup
**Root cause:** On second-device setup the client generates a keypair and trusts the server-provided public certificate without checking that the private key corresponds to the previously downloaded public key, as the RFC requires.
**Steps:**
1. userA enables E2EE on serverA, sets up device1, stores nonce, uploads data
2. Evil admin replaces userA's public key on the server with attacker's key
3. userA sets up device2 and enters the nonce
4. Client generates/uses keypair without verifying it matches the stored public key
5. userA uploads more data; it is encrypted to the attacker's key
6. Attacker decrypts the uploaded data
**How found:** Reporter compared platform behavior: iOS encrypts/decrypts a test string binding the keypair, while Desktop/Android do not, and noticed the RFC explicitly requires the client to check the private key belongs to the previously downloaded public certificate.
**Exploitation:** Requires server/admin compromise. Admin swaps the victim's public key; victim's next device setup silently encrypts new uploads to the attacker key, giving the admin plaintext access to data that E2EE was meant to protect from the server.
**Insight:** When auditing E2EE clients, check whether key setup binds the private key to the server-stored public key; platforms that skip a test-encrypt/decrypt round-trip during device enrollment are candidates for malicious-server key substitution.

