End to end encryption public key is not properly verified on Desktop and Android
When a second device is set up for end-to-end encryption, the client does not verify that the private key matches the previously downloaded public key. A malicious server administrator could swap the user's public key for their own, so data uploaded from the new device is encrypted to the attacker's key.
- Triaged in 35 hours
- Fixed in 3 months
- Paid in 11 days
- Disclosed after 5 months
Since last time when I reported something on multiple platforms you seems to prefer handling it in 1 spot. I now just do one. Let me know if You want me to fill separate for android as well. This issue does not seem to happen on iOS as there a test string is encrypted and decrypted, in short binding the keypair.
So the attack vector results in weird behavior but that seems to be due to random bugs in the end to end encryption implementations (because I also ran into those when just messing around with the end to end encryption). In any case there should be a big error if this happens.
- userA has an account on serverA
- End2End encryption is enabled on serverA
- userA setups device1 and enabled end to end encryption. Stores the nonce. Uploads some data. All is good.
- Now an attacker obtains access to the server, for sake of argument assume there is an evil Admin.
- They replace the public key of userA with their own
- userA now setups device2
7, userA enters the nonce 8. userA uploads more data 9. the evil admin now has access to the uploaded data
Impact
In short it breaks the whole premise of your end to end encryption. An evil admin is able to make the device encrypt to their key.
It is even in the RFC: https://github.com/nextcloud/end_to_end_encryption_rfc/blob/master/RFC.md#further-devices "Client checks if private key belongs to previously downloaded public certificate."
Recommendations:
- the clients should verify that the private key matches with the public key and if not throw a big error
This is especially important because somebody is clearly doing something they are not supposed to if this happens.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the client trusts the public key supplied by the server when adding a device and never checks that the device's private key corresponds to the previously stored public key.
Impact
An evil administrator could read data uploaded from a newly set up device, breaking the premise of end-to-end encryption; the reporter notes the behaviour also produced odd results from unrelated bugs in the encryption implementation.
What the attacker needed
Attacker controls the server; victim sets up a new device; victim enters the nonce
The fix
Clients should verify that the private key matches the public key and raise a clear error when it does not.
How it was found
- A user has an account on a server with end-to-end encryption enabled.
- The user sets up a first device, stores the nonce and uploads data.
- An attacker with server access replaces the user's public key with their own.
- The user sets up a second device and enters the nonce.
- The user uploads more data, which is now encrypted to the attacker's key.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
End-to-end encryption means only your devices can read your data, not the server. Each device has a key pair: a public key others use to lock data and a private key that unlocks it. Here the app never checked that the private key on a new device actually belongs to the public key the server handed out, so a dishonest server operator could give out their own public key and read what the user uploads.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.