Kunzisoft / KeePassDX

Lightweight vault and password manager for Android, KeePassDX allows editing encrypted data in a single file in KeePass format and fill in the forms in a secure way.
https://www.keepassdx.com/
GNU General Public License v3.0
4.35k stars 262 forks source link

image key file hmac mismatch on Android 12 #1188

Open rebior opened 2 years ago

rebior commented 2 years ago

Describe the bug For a short time now (since mid of December 2021) I am not able to open my password database with key file any longer. To find the problem I cloned the repo, started debugging the app and found the following:

So it looks like it is an issue with the newest Android system with Android 12 (ABI x86_64 and API 31)

Expected behavior The database should load.

KeePass Database

KeePassDX (please complete the following information):

Android (please complete the following information):

J-Jamet commented 2 years ago

I just tested on emulator and I have no problem. Can you upload a test database file with its key file so that I can reproduce the issue?

content:// is visible when you go to the database history by clicking on the arrow next to a file name.

rebior commented 2 years ago

Ok, I can now give more precise instructions to reproduce the issue: It happens with a .jpg image as key file that contains the GPSVersionID exif tag (e.g. GPSVersionID=2.3.0.0). It looks like Android somehow modifies the content of the file when KeePassDX reads it. When I change the extension to .bin everything works. When I remove the GPSVersionID it also works. I've attached such an image test .

J-Jamet commented 2 years ago

Indeed, the header hmac does not give the same result with the .jpg extension and without extension, which is very strange. If the new system starts to modify the data provided from files, it's a bad start. :D

I'll see if there are any new options to add in the stream requests for this problem.

J-Jamet commented 2 years ago

I've done several searches and haven't found a viable way, I think the data is modified by the file provider in the "Files" application of the device before being sent to the stream. So the only solution I see for now is to modify the extension.

rebior commented 2 years ago

I also tried to give the app location permissions, but that also didn't help. For me it looks like a bug in Android 12. Initially this worked on my Pixel 6, so it was introduced some time in December. The only thing I can imagine is that this is a feature that should prevent circumventing the location permissions by scanning images to get the location. But this is rather useless if renaming the image can be used to circumvent this feature...

rebior commented 2 years ago

Will you report this as a bug in Android?

J-Jamet commented 2 years ago

It should be. Anyway, now that the bug is in production in the Google OS, I'll have to manage a warning message to warn the user, so I'll do that already.

J-Jamet commented 2 years ago

Issue open : https://issuetracker.google.com/issues/218668344 (previous https://issuetracker.google.com/issues/216592436) Test app : https://github.com/Kunzisoft/SAFIntegrity