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.69k stars 276 forks source link

I cannot open the database after android 12 update in my Samsung Galaxy A52 #1209

Closed razercrypto closed 1 year ago

razercrypto commented 2 years ago

Describe the bug I cannot open the database after android 12 update in my Samsung Galaxy A52. After I entered the password and press open it shows "Could not load your database. java.lang.SecurityException: com.android.externalst..." .

KeePassDX (please complete the following information):

Android (please complete the following information):

Error

J-Jamet commented 2 years ago

This exception indicates that the application no longer has the rights to access a particular URI. What type of URI are you trying to access?

If you use a key file, reselect it from its location. Similarly for database files, just reopen them from their location. In case you use a URI link with an icon, make sure you are not in the same situation as this one : https://github.com/Kunzisoft/KeePassDX/discussions/1089#discussioncomment-1985550

Link to https://github.com/Kunzisoft/KeePassDX/issues/1172

razercrypto commented 2 years ago

I have a kdbx database with keyfile, I tried all the methods you mentioned but it doesn't work. I created a new database without keyfile (database is located in main internal storage directory) to see whether the problem is associated with a keyfile or not , Iam able to create the database but when I try to reopen I see this same error. So I created another database which is located in the downloads folder, It works fine without keyfile. When I try to add keyfile through the app settings it shows "com.android.externalstorage has no access to content://media/external_primary/file/1531" .

J-Jamet commented 2 years ago

In this case it is because you do not have the permission to manipulate files in the folder where you want to put it. These are Android 12 restrictions (since Android 11). https://stackoverflow.com/questions/67367047/android-11-primary-directory-invalid-not-allowed-for-content-media-external If you go through Material Files, do you also have the problem?

razercrypto commented 2 years ago

I had no issues like this when I was using Android 11. I tried Meterial files. Iam unable to open keyfile or database with the meterial files. No external file manager app is showing when Iam trying to open from the keepass app. So I opened Meterial files and opened that kdbx database with keepass. Database without keyfile works fine(Both main internal storage and downloads folder). But when I try to open a database which has a keyfile or when I try to add the keyfile through the app settings after the initial database creation , I see the same error(error1 and error 2) I mentioned above.

J-Jamet commented 2 years ago

In this case, it is not the location of the database file but the location of the key file that is the problem. I guess it is not stored right next to your database.

razercrypto commented 2 years ago

It wasn't stored right next to database. But I tried keyfile right next to database but it doesn't work.

J-Jamet commented 2 years ago

If you tell me that it was working before the update of your phone. The most likely hypothesis is that a behavior has changed on your device. Because on KeePassDX, I haven't changed anything regarding file permissions, which still use the same SAF code. You should do more tests to see what works and what doesn't, I know Android 12 can generate an hmac mismatch exception if a key file is an image #1188 which is not your case so it is to be excluded. Theorically, a security exception only happens if the access is revoked by the system, the KeePassDX code does not generate any of this type so I don't see what to improve in KeePassDX especially since I have no problem on emulator.

J-Jamet commented 2 years ago

Do you have new information about your problem?

razercrypto commented 2 years ago

Problem is related with the default file manager.

fifi634 commented 2 years ago

For information, I have exactly the same problem with my Sony Xperia2 and Android 9. This issue is come just after the last upgrade of KeepPassDX. My datafile is stock in main storage and it is synchronise with nextcloud. Before upgrade, it 's work normaly. After, it' s work when I pick a datafile manualy and I'm connect with my pass, biometric empreint doesn't work. I hope my message help you, thanks for your app.

J-Jamet commented 2 years ago

@fifi634 It doesn't really help because I didn't change the file stream method in the last KeePassDX updates, so I don't see how the program can be at fault.

fifi634 commented 2 years ago

Yes I know, I've read all comment before. It's a mistery. If I find a clue I post her.

fifi634 commented 2 years ago

For information, the database works correctly now on my Xperia XA2 with a nextcloud's synchronisation (i've had this issue before). I've just check a .kdbx files in favorit (in a start page). After the update its's worked with step. Thanks for your app.

SyaX34 commented 1 year ago

Hello @razercrypto, you should try giving all files permission to the application called "external storage".

To do this

  1. Open the settings
  2. Scroll down and press the button that says apps
  3. Press the three dots located at the top right.
  4. A few fields should pop up, press "special access"
  5. Press "All File Access", you can't miss it. It should be at the top of the list
  6. Make sure you toggle blue the app called "External Storage". You may have to scroll down to find the app.

Instructions could be different in some devices. App name should be exactly the same, at least the package name should be exactly the same.

I was having this issue recently with KeepassDX and Keepass2Android. This is how I was recently able to fix this issue on my Samsung Note 20 Ultra 5G. While investigating this issue I also found I was only able to access databases if they were created by the app, moving the file and accessing it from that new location would cause this issue to happen again. I believe this is android 12 working exactly as intended, except, "com.android.externalstorage" did not have All File Access permission for some reason on some devices. It is possible that I removed the permission during my debloat, but, why would I do that? Maybe an accident, unless more than a few people have this problem. I should also add this happened on a phone I bought very recently, no update, this is how it arrived, it was already on Android 12 and I updated for the first time after the issue happened.

Please let us know if this fixes your issue, if it doesn't I hope this information can be helpful in providing an update that will fix this issue.

(Although irrelevant, if someone has this issue on Keepass2Android, the error message should be "Could not access source file: com.android.externalstorage has no..." it cuts off on my device.)

razercrypto commented 1 year ago

Thank you for the information. Keepassdx is not listed in All files access and storage permission is removed from the new version. I tried the old version which has storage permission but it is also not listed in All files access. I got the Android 13 update and updated last month. So in that, it works with the ZArchiver file manager without issues.

SyaX34 commented 1 year ago

You should not have "KeepassDX" listed under All File Access.

You should have "External Storage" listed there. It's a system app that should come preinstalled on your device.

Note: Google Play is very strict on what app is allowed to have the All File Access permission. KeepassDX and Keepass2Android could be removed if they asked for that permission.

razercrypto commented 1 year ago

Thank you very much. I was wondering why external storage is not showing with default file manager after the update, now it is showing and it works with android 13.

SyaX34 commented 1 year ago

Great to know!

J-Jamet commented 1 year ago

Wiki updated regarding new procedure