element-hq / element-hq/element-android

Cannot decrypt messages from specific user sent using specific device: `Unable to decrypt: OLM`

Open
#3,429 17 comments 15 reactions 1 assignee Claimed by @BillCarsonFr View on GitHub
Team: Crypto
Dominant language
Kotlin
Stars
3.7k
Forks
917
Avg merge
8d 20h
Merged PRs (30d)
1

Description

#### Describe the bug

When using Element Android on a phone running Android 10, E2E messages received from one specific device belonging to another user are not immediately viewable. Instead, `Waiting for this message, this may take a while` is seen in place of the message contents, or `** Unable to decrypt: OLM **` when Developer mode is turned on in Element's advanced settings.

#### To Reproduce

A room exists consisting of me and my friend Ed, each using our own, self-hosted Synapse homeservers. We have not tested for this issue in other rooms.

Steps to reproduce the behavior:

1. Ed uses his phone to send a message to this room.
2. I observe the following:
a. On my phone running Android 10: Often `Unable to decrypt: OLM` is shown in place of the message contents. Otherwise, the message contents are visible, as expected.
b. On my phone running Android 6: The message contents are visible, as expected.
c. On my computer with Element Desktop: The message contents visible, as expected.

For comparison, we tested the following:

1. Ed uses his computer with Element Desktop to send a message to this room.
2. I observe the following:
a. On my phone running Android 10: The message contents visible, as expected.
b. On my phone running Android 6: The message contents are visible, as expected.
c. On my computer with Element Desktop: The message contents are visible, as expected.

We also tested:

1. I use my Android 10 phone to send a message to this room.
2. On Ed's phone: The message contents are visible, as expected.

Finally, we tested:

1. In a new room, without E2E enabled, Ed uses his phone to send a message to the room.
2. I observe the following:
a. On my phone running Android 10: The message contents are visible, as expected.
b. On my phone running Android 6: The message contents are visible, as expected.
c. On my computer with Element Desktop: The message contents are visible, as expected.

Each test consisted of Ed (or myself) sending multiple messages in quick succession, and the 'failure' rate for my ability to view messages on the affected phone was 100%. But under normal, "real life" circumstances (i.e. an actual conversation), this only occurred once every few messages.

I've concluded that this issue only affects messages sent from Ed's phone when they're viewed on my Android 10 phone, and in a room with E2E enabled.

On the affected (Android 10) phone, logs were captured using `logcat` over `adb`. The following is shown repeatedly when affected messages are received:

```
05-24 21:55:02.212 27914 1430 E OlmJniNative: ## decryptMessageJni(): failure - olm_group_decrypt Msg=BAD_MESSAGE_MAC
05-24 21:55:02.212 27914 1430 E OlmInboundGroupSession: ## decryptMessage() failed BAD_MESSAGE_MAC
```

The affected messages eventually become visible on the Android 10 phone, but I have not figured out how long the delay actually is. It appears to be greater than a few hours.

This issue has not affected communications with any other users yet.

#### Expected behavior

When Ed sends me a message, it will be viewable on every device I have Element and E2E correctly set up on in a reasonable amount of time, regardless of which of his devices he uses to send it.

#### Screenshots

Screenshots have been attached.

#### Smartphone (please complete the following information):

##### My phone affected by this issue

- Device: Motorola Moto Z3 Play
- OS: Android 10 (LineageOS 17.1, official, build 17.1-20210303-NIGHTLY-beckham)

##### My phone unaffected by this issue

- Device: Motorola Moto X
- OS: Android 6 (LineageOS 14, unofficial, self-built)

##### Ed's phone

- Device: Google Pixel 3
- OS: Android 11

#### Additional context

- Using Element Android: 1.1.7 via Google Play (Applies to all phones listed above)
- Homeserver: matrix.calvinrw.com (Synapse 1.34)
- Ed's homeserver: Synapse 1.34
- Two rageshakes were submitted on 2021-05-23
- This issue did not occur prior to 2021-05-05, and started occurring consistently after 2021-05-10.
- E2E appears to be set up correctly on all devices, because Element shows the green shield for this room. We have verified each other, and all of our sessions are verified.
- Before and during the tests described above, both of my phones were kept awake using LineageOS's caffeine feature, so Android's power management was not a factor.

![Screenshot_Android6_20210523-134331_resize](https://user-images.githubusercontent.com/687129/120088961-9c61bb00-c0bb-11eb-9a45-4c878768f753.png)
![Screenshot_Android10_20210523-134337_Element_resize](https://user-images.githubusercontent.com/687129/120088962-9c61bb00-c0bb-11eb-952f-bd62a9cd4033.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.