Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash Either the encryption key is incorrect or data is corrupted with reproducible .ream file #8055

Closed
JohnnyTseng opened this issue Dec 3, 2024 · 12 comments
Assignees

Comments

@JohnnyTseng
Copy link

JohnnyTseng commented Dec 3, 2024

Hello,

We've upgraded our Realm SDK from 10.45.1 to 10.54.0, after that, we are receiving ~2000 crashes per day
All crashes points to same error message:

Fatal Exception: realm::util::DecryptionFailed
Decryption failed: page _[random number]_ in file of size _[random number]_ failed the HMAC check. Either the encryption key is incorrect or data is corrupted 

The only thing we did is upgrade Realm SDK version. We've managed to retrieve a db file that is having this issue
(I have sent it to [email protected], title is: Realm file for issue #8055 and #8719)

SDK and version

SDK : Cocoa
Version: 10.54.0

Observations

  • How frequent do the crash occur?
    Affected thousands of our users

  • Does it happen in production or during dev/test?
    Both production and dev/test environment

  • Can the crash be reproduced by you?
    N/A

  • Can you provide instructions for how we can reproduce it?
    Cannot be steadily reproduced, but we do have a realm db file that encountered this issue

Crash log / stacktrace

Fatal Exception: realm::util::DecryptionFailed
Decryption failed: page 65 in file of size 1069056 failed the HMAC check. Either the encryption key is incorrect or data is corrupted 0 
Realm 0x0000000105ac5e80 _ZN5realm4util16DecryptionFailed19get_message_with_btENSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE + 60 1 
Realm 0x0000000105ac61ec _ZN5realm4util16DecryptionFailedC2ERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEE + 56 2 
Realm 0x0000000105c67134 _ZN5realm4util20EncryptedFileMapping22throw_decryption_errorEmNSt3__117basic_string_viewIcNS2_11char_traitsIcEEEE + 152 3 Realm 0x0000000105ac53a4 _ZN5realm4util20EncryptedFileMapping12refresh_pageEmb + 396 4 
Realm 0x0000000105ac5a50 _ZN5realm4util20EncryptedFileMapping12read_barrierEPKvmb + 252 5 
Realm 0x00000001057fcb0c _ZNK5realm9Allocator18translate_criticalEPNS0_14RefTranslationEm + 200 6 
Realm 0x0000000105938cac _ZN5realm13BPlusTreeBase20create_root_from_refEm + 60 7 
Realm 0x0000000105950c10 _ZN5realm14CollectionBase19do_init_from_parentEPNS_13BPlusTreeBaseEmb + 36 8 
Realm 0x00000001059d517c _ZNK5realm6LnkLst4sizeEv + 28 9 
Realm 0x00000001057f20c4 -[RLMManagedArray count] + 28 10
Realm 0x00000001057caf94 -[RLMArray lastObject] + 20 11 
RealmSwift 0x0000000104ee6858 $s10RealmSwift0A14CollectionImplPAAE5first7ElementQzSgvgTm + 76 12 
RealmSwift 0x0000000104ee89dc $s10RealmSwift4ListCyxGAA0A10CollectionA2aEP4last7ElementQzSgvgTW + 80 13 

Steps & Code to Reproduce

@BlueCobold
Copy link

BlueCobold commented Dec 3, 2024

Note: Realm-Swift v10.54.0 contains Realm-Core v14.13.0. While I did have (a lot of!) issues with corrupted files in the past, I currently run on core 14.12.1 (iOS) and 14.7.0 (Android) without reports. Might be a regression in v14.13.0.

(The 20.1.1, 20.1.0 and 14.13.2 release notes are not included in the CHANGELOG.md btw)

@JohnnyTseng
Copy link
Author

Note: Realm-Swift v10.54.0 contains Realm-Core v14.13.0. While I did have (a lot of!) issues with corrupted files in the past, I currently run on core 14.12.1 (iOS) and 14.7.0 (Android) without reports. Might be a regression in v14.13.0.

(The 20.1.1, 20.1.0 and 14.13.2 release notes are not included in the CHANGELOG.md btw)

Hi @BlueCobold

Is your crash / error message same as mine after upgrading Realm iOS SDK version?

Either the encryption key is incorrect or data is corrupted

Thank you!

@BlueCobold
Copy link

BlueCobold commented Dec 3, 2024

@JohnnyTseng I did have this kind of error message ("HMAC check") as well. Among various others or similar ones. The problems were manyfold.

If you have the file at hand, did you by chance try using the command line tools to decrypt the file, to use the trawler or to open it via RealmStudio?

@JohnnyTseng
Copy link
Author

@JohnnyTseng I did have this kind of error message ("HMAC check") as well. Among various others or similar ones. The problems were manyfold.

If you have the file at hand, did you by chance try using the command line tools to decrypt the file, to use the trawler or to open it via RealmStudio?

@BlueCobold

I have tried using RealmStudio to open the DB file; however, it still fails. I guess the DB file is already corrupted 🥲

@BlueCobold
Copy link

@JohnnyTseng It certainly sounds like if that error is given. Does your app access the realm file in single or in multi-threading?

@jedelbo
Copy link
Contributor

jedelbo commented Dec 9, 2024

I currently run on core 14.12.1 (iOS) and 14.7.0 (Android) without reports. Might be a regression in v14.13.0.

There is no changes relevant to this issue from 14.12.1 to 14.13.0.

@jedelbo
Copy link
Contributor

jedelbo commented Dec 9, 2024

@JohnnyTseng In order to progress on this, I would need a realm file together with the encryption key used. You can share that privately with me on [email protected]

@jedelbo jedelbo self-assigned this Dec 9, 2024
@JohnnyTseng
Copy link
Author

Hello @jedelbo ,

Thank you for replying, I have sent the key through the mail!

@jedelbo
Copy link
Contributor

jedelbo commented Dec 9, 2024

I have tried to open the received file using the key, I got. It fails the HMAC check as described above. The file itself looks ok, but of course just a single bit wrong will make the check fail. However, I would say that the chance that there is a problem with the encryption key is pretty high.

If you can somehow reproduce the error locally, I will be happy to help the investigation.

@JohnnyTseng
Copy link
Author

Thank you @jedelbo , I'll close this issue!

@BlueCobold
Copy link

What was the final outcome?

@JohnnyTseng
Copy link
Author

@BlueCobold We did not find the root cause of this issue, became a mystery.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants