element-hq / element-android

A Matrix collaboration client for Android.
https://element.io/
GNU Affero General Public License v3.0
3.35k stars 711 forks source link

[SSSS] User password is asked multiple times then the app crashes when trying to reset the recovery key. #8861

Open yostyle opened 3 months ago

yostyle commented 3 months ago

Steps to reproduce

case 1:

  1. Go to Settings > Security & Privacy
  2. In Secure Backup section tap on "Set up on this device".
  3. Choose "Reset everything"
  4. Tap on "Proceed to resest"
  5. Select "Use a Security Key"
  6. Enter your password

https://github.com/element-hq/element-android/assets/1191674/c1927459-a64c-4f03-8701-2f3dc43148e4

case 2:

  1. secure_backup_required is enabled in wellknown configuration
  2. Log in to Element Android
  3. Choose "Reset everything"
  4. Tap on "Proceed to resest"
  5. Select "Use a Security Key"
  6. Enter your password

https://github.com/element-hq/element-android/assets/1191674/8914c624-80eb-40f3-a174-2af753594af2

Outcome

What did you expect?

Get a recovery key

What happened instead?

User password is asked multiple times and the app crashes.

bootstrapTask invoked from startInitializeFlow method is called multiple times :

Your phone model

Pixel 8 Pro

Operating system version

Android 14

Application version and app store

Element 1.6.16

Homeserver

matrix.org

Will you send logs?

No

Are you willing to provide a PR?

No

yostyle commented 3 months ago

@bmarty @BillCarsonFr We need to understand why startInitializeFlow method may be called multiple times ? If not what is the right way to fix that ?

yostyle commented 3 months ago

What do you think about those following quick fixes ?

https://github.com/tchapgouv/tchap-android/blob/216762a06bd7c31fa2c9ea7417006863426bed1f/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSharedViewModel.kt#L231

https://github.com/tchapgouv/tchap-android/blob/216762a06bd7c31fa2c9ea7417006863426bed1f/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSharedViewModel.kt#L218

BillCarsonFr commented 2 months ago

@bmarty @BillCarsonFr We need to understand why startInitializeFlow method may be called multiple times ? If not what is the right way to fix that ?

Hello @yostyle , I suspect that what you are seeing is a regression due to https://github.com/element-hq/element-android/pull/8786

When UIA kicks in, the state is set to ReAuth step that will then show the ReAuthFragment that then does an auto submit (calling again startInitializeFlow) https://github.com/element-hq/element-android/blob/b0158f1a93499b736a92285d8a7359a51a2d8921/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt#L48-L52