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.49k stars 266 forks source link

Access to the file revoked by the file manager #626

Closed jvc2015 closed 2 years ago

jvc2015 commented 4 years ago

Hi,

I make my file of database in root directory of my cellphone. They haved many passwords. But, today don't can open my database why don't have access to the file by the file manager. Opened my file manager ES File Explorer Pro, i don't exist my file of database anymore Please help me to search the file, why i can't find It in any directory of my data storage, too Is possible find a programated task of cleaning un the file manager. My cellphone Is Ulefone Amor 5S Android version 9 KeePass version 2.7 File manager: ES File Manager v4.2.2.1

Sorry for my english, i speak spanish lenguaje. Thanks for your help

J-Jamet commented 4 years ago

Hello, no worries about the English language, I am not an English speaker either.

Regarding your problem, I can't really help you. It's like telling me that you lost a file in the architecture of your hard drive. I have no way of knowing where it is. KeePassDX is a file editor and not a file manager, so it does not know directly where the files are stored, it only knows the file URIs (it's a bit like URLs for websites, the browser does not don't know where the files are stored on the remote server, there are only requests and streams) This allows KeePassDX to never have direct control over the file so as not to be in charge of disk operations.

I'm not familiar with ES File Explorer Pro but maybe only the URI was invalidated and your file is where you saved it the first time. Or maybe this app deleted the file somehow, I don't know. I can only add information to the wiki about this file manager if I do more testing.

whoizit commented 4 years ago

long tap on the open button will open the file in the default file manager, but this does not solve this issue. Earlier, I haven't problem with it,

whoizit commented 4 years ago

and no, I have another problem. I don't have a path to the database, I have to reopen it every time, cause ~'file access is cancelled by the file manager'

J-Jamet commented 4 years ago

@whoizit You do not specify which file manager you are using. If it revokes the link every time, I'll add the you're app to the wiki: https://github.com/Kunzisoft/KeePassDX/wiki/File-Manager-and-Sync

whoizit commented 4 years ago

default file manager com.android.documentsui from crDroid Android 9 firmware and over CX Explorer 1.4.1 com.cxinventor.file.explorer

used to work with at least a default file manager. It doesn't work anymore.

J-Jamet commented 4 years ago

In this case, I recommend that you use another file manager that does not cancel links during an ACTION_OPEN_DOCUMENT. Or request behavior change in CX Explorer.

used to work with at least a default file manager. It doesn't work anymore.

I haven't changed anything on my side, so something outside must now invalidate your links.

whoizit commented 4 years ago

maybe syncthing changes the time of file change and it breaks?

J-Jamet commented 4 years ago

Yes that's a possibility, I don't use Syncthing. We have to test.

whoizit commented 4 years ago

after a long tap to open button, it opens in the default file manager and the path to the file is this: /document/primary:sync/keepassxc/passwords.kdbx

If I close and reopen the KeePassDX, the path to the file is - /root/storage/emulated/0/sync/keepassxc/passwords.kdbx and file access is cancelled by the file manager

J-Jamet commented 4 years ago

The long click is only an alternative solution which uses the Intent ACTION_GET_CONTENT. This is not the normal method used by SAF to open documents over the long term, so this is normal. It is a opening solution for old file managers which are not yet up to date. Whenever possible, try to use the single click that calls ACTION_OPEN_DOCUMENT for native integration with file manager.

metakaos commented 4 years ago

after a long tap to open button, it opens in the default file manager and the path to the file is this: /document/primary:sync/keepassxc/passwords.kdbx

If I close and reopen the KeePassDX, the path to the file is - /root/storage/emulated/0/sync/keepassxc/passwords.kdbx and file access is cancelled by the file manager

One workaround that's working for me so far was hitting the back arrow button next to that path once the database was open and setting that database as a favorite (star), so it opens it using /document/primary:sync/keepassxc/passwords.kdbx every time instead of trying to use /root/storage/emulated/0/sync/keepassxc/passwords.kdbx

This is with Cx File Explorer, btw

whoizit commented 4 years ago

It seems to be decided for me. I do not know how. At first it seems to have helped to remove Cx File Explorer, but now it works with it as well.

Michas0206 commented 3 years ago

Same (?) problem on 2 mobiles since last update - it tells me every time I open KeepassDX " file not found please open the file manager" and access refused by filemanager. Some weeks ago everything was fine, I am not 100% sure if the last update caused it, but it looks so.

Very annoying as I now have to close the warnings and reselect the keepass file every time.

OS on both mobiles is LOS 17.1.

J-Jamet commented 3 years ago

@michas0602 I am almost sure that the problem does not come from the update of KeePassDX since the SAF which manages the URIs of the databases has not been modified for a long time. You haven't indicated which file manager you are using (and whether it has had an update). The problem could also be a link that you favored with the star trying to be opened when it is broken. Try to put the star on the new link you select. https://www.reddit.com/r/KeePass/comments/k5j6k3/keepassdx_access_to_the_file_revoked_by_the_file/

Michas0206 commented 3 years ago

I just dont know what else could cause this - especially on my second mobile. File manager is LOS-standard + Total Commander. Another thing I've seen is that the message occurs if I open Keepass through MagiKeyboard and if I open the app. But why does it open my keepass-file normal through the app if I press back one time in the app and select the file (I have just one) without any error?

But when I open the app, it always says "/document/2160" and the error-message "access denied by filemanager" or something like this.

What exactly has the filemanager to do with this access? Is there a place for keepass-file where I can copy it fir a test where it definately should work? Strange thing to me is that everything was fine here a few weeks ago - and I have not moved my keepass-file.

Michas0206 commented 3 years ago

To proof I just reinstalled older 2.9.1 from Github here - works like a charm, no problem anymore here on mobile 1...maybe I do more tests tomorrow, but as said - 2.9.1 does not make this problem here.

J-Jamet commented 3 years ago

I just dont know what else could cause this - especially on my second mobile. File manager is LOS-standard + Total Commander. Another thing I've seen is that the message occurs if I open Keepass through MagiKeyboard and if I open the app. But why does it open my keepass-file normal through the app if I press back one time in the app and select the file (I have just one) without any error?

I have already answered the question, you have stared a broken link. Please read the previous answer carefully. You can see broken links in favorites with Settings -> App Settings -> Hide broken database links

But when I open the app, it always says "/document/2160" and the error-message "access denied by filemanager" or something like this.

Because the database link you want to open has been broken by the file manager.

What exactly has the filemanager to do with this access?

The File Manager is the app that provides the URI link to KeePassDX to retrieve the data from the file. https://github.com/Kunzisoft/KeePassDX/wiki/File-Manager-and-Sync This wiki explains very well how URIs work

Is there a place for keepass-file where I can copy it fir a test where it definately should work?

All locations authorized by your file manager which keeps links.

Strange thing to me is that everything was fine here a few weeks ago - and I have not moved my keepass-file.

Your file manager has invalidated a link for reason X or Y (time, file modification, ...)

To proof I just reinstalled older 2.9.1 from Github here - works like a charm, no problem anymore here on mobile 1...maybe I do more tests tomorrow, but as said - 2.9.1 does not make this problem here.

This is not proof at all, it just means you have a different link that works on another device. It is possible but tell me exactly what is the change in this version that is causing the problem.

guillp commented 3 years ago

FYI I had the same issue on my OnePlus Nord and it looks like it has been fixed by an update of OnePlus FileManager on 29/12/2020.

junetried commented 3 years ago

I'm not sure what I changed but as of recently I'm having this issue too. I use Material Files which is said to work fine. May or may not be related but the app is now unusably slow (several seconds of pauses) when trying to open a database. Opening a database instantly says 'access revoked by the file manager'.

pepa65 commented 3 years ago

One workaround that's working for me so far was hitting the back arrow button next to that path once the database was open and setting that database as a favorite (star),

Yes, this worked when I encountered "Access to the file revoked by the file manager" all the time. Once it's starred, it's apparently OK to remember the path..?

E0697 commented 3 years ago

This has been happening a lot recently! It was working perfectly before. I noticed a recent update of the Files app, which could be the cause here. When I encounter it, quiting KPDX and removing it from the recents menu and then launching it again fixes it. Any thoughts?!

horbo commented 3 years ago

Hello! I have the same problem! Sometimes Keepass show the "Access to the file revoked by the file manager", don't know what triggers that. The file exists, and message still remains if I select the file manually in the app once again.

The message disappears only after restarting the phone or force-closing the app using Android settings menu.

Also, file disappears from the favourites list and coming back again after restart.

I'm using Syncthing to sync files among my devices, but the problem started occurring maybe a few weeks ago.

E0697 commented 3 years ago

Hello! That's exactly what's happening for me. I'm using a local database and syncing it to the cloud.

fevieira27 commented 3 years ago

The same issue has indeed happened to me today for the first time. I'm using Google files with the DB stored on drive.

For now, clicking on the back arrow and opening the DB in keepass DX again from scratch did solve the issue. It could have been due to a files update that happened 2 days ago (I'm on their beta channel), so hope the error doesn't come back.

soredake commented 3 years ago

This started to happen VERY often with keepassdx from gplay + google drive client.

soredake commented 3 years ago

This happen reliably after 2-4 days.

auanasgheps commented 3 years ago

It keeps happening. A lot since the last weeks, a Google Drive DB via the system's file manager of Android 11. Is this expected?

mavaa commented 3 years ago

Experienced this very recently as well. My issue was (possibly) related to having the file in nextcloud. Every time the file changed from an external machine I would get this issue. Tried today to force stop KeePassDX, Clear data & cache and open the app again. After that it worked, and has done so for some hours now, even after changing my db file several times.

Not sure what caused this to begin with, but I'll report back if it starts again.

soredake commented 3 years ago

@Kunzisoft @J-Jamet @bpellin

J-Jamet commented 3 years ago

https://github.com/Kunzisoft/KeePassDX/wiki/File-Manager-and-Sync#explanation

soredake commented 3 years ago

@J-Jamet so, there is nothing can be done from keepassdx side?

horbo commented 3 years ago

@J-Jamet

https://github.com/Kunzisoft/KeePassDX/wiki/File-Manager-and-Sync#explanation

I use Syncthing to sync db file among my devices - on the phone file is stored locally, so i don't have to use any file manager (beside one built-in in android), thus there is no way to file link to be broken. If file would be broken, reselecting the database should help, but it doesn't. I have to force close the app to start work again :(

soredake commented 3 years ago

As temporary alternative there is https://github.com/PhilippC/keepass2android and https://github.com/authpass/authpass which support gdrive natively.

J-Jamet commented 3 years ago

Experienced this very recently as well. My issue was (possibly) related to having the file in nextcloud. Every time the file changed from an external machine I would get this issue. Tried today to force stop KeePassDX, Clear data & cache and open the app again. After that it worked, and has done so for some hours now, even after changing my db file several times.

@mavaa It is not normally necessary to make a clear cache. Here it worked for you simply because you reselected the file after the clear which generated a new URI from NextCloud. Re-selecting the file from Nextcloud would have been the same.

so, there is nothing can be done from keepassdx side?

@soredake It is possible to improve the reading of the stream (what I have already done and don't see how to improve), but not all the problems you describe are due to a stream reading. Here it is simply that the URI delivered by the third app that accesses the file does not provide a stream anymore or changes the metadata of this URI. I repeat it but it is as if the internet address (URL) changed (the server changed its configuration), you may have a bookmark on your browser (here corresponds to the history of KeePassDX), if the address pointed to is no longer the same, there is nothing to do by the client.

I use Syncthing to sync db file among my devices - on the phone file is stored locally, so i don't have to use any file manager (beside one built-in in android), thus there is no way to file link to be broken.

@horbo You can't use KeePassDX without a file manager, as you say, there is one by default in your system otherwise you won't even be able to read a file if the URI is not linked to a data stream.

If file would be broken, reselecting the database should help, but it doesn't. I have to force close the app to start work again :(

This case is very strange, it is not necessary to kill KeePassDX. Basically the URI flow is initialized when the activity is created so closing KeePassDX normally and reopening it should reset the flow initialization. After all it depends on your OS, many Android devices replace the File system of the AOSP with a proprietary file manager, this is the case of Samsung, Xiaomi, Huawei and many others. Can you tell me what is the package name of your file manager and its version?

But again, you should see the KeePassDX URI history only as a help. It's like opening your text file editor on your PC and viewing recent files. In 90% of the cases, users use their PC's file manager to access a file and do not use the recent files editor. They know that it may become inaccessible to the app editor, why does it become a huge problem to select it from its location when you use a phone? Do you think I should make this history less accessible or just hide it by default so that users mainly use the open button or go through their file manager to select a file?

horbo commented 3 years ago

@J-Jamet

You can't use KeePassDX without a file manager, as you say, there is one by default in your system otherwise you won't even be able to read a file if the URI is not linked to a data stream.

Yes, I meant that I am not using any custom file managers for KeePass, especially those that store files in the cloud (Google Drive, One Drive etc.). What I wanted to point out is, I store kdbx file locally on the phone memory, and use default file manager to select the file in KeePass. Can't find an appId of the default file manager though. I'm using Galaxy S9+, and when selecting a file, KeePass uses default file selector.

As per killing the app. When problem occurs, I can even delete a database file from recent list, and select it once again using file selector, the message Access to the file revoked by the file manager still remains.

JourPT commented 3 years ago

I had this error minutes ago, without my knowledge my SD card (where I store my database file) had for a strange reason unmounted. After I rebooted and the card correctly mounted, everything was fine again. I know it might not be the case for everyone but I got this exact error and this how I solved it. Best regards.

J-Jamet commented 3 years ago

@horbo You can easily see the package of an application with https://github.com/MajeurAndroid/android-applications-info. You have a Galaxy S, I think your default manager is the one from Samsung (second to last in the list https://github.com/Kunzisoft/KeePassDX/wiki/File-Manager-and-Sync)

I can even delete a database file from recent list

That's strange, it means that the manager ignores the delete requests. If you show me the package with the tool mentioned above, I can investigate.

J-Jamet commented 3 years ago

@JourPT In your case it is normal, thanks for the feedback.

TakeshiKovacs999 commented 3 years ago

I have this issue as well. I have tried both local and on google drive. Seems to be a path and permission issue. I wonder if google changed a rule in file manager that is causing this issue... I just have to reselect the file which must fix the path as well as correcting the permission issue. I'm just running a stock pixel 4a on Android 11. Perhaps but I'm only guessing accessing log files not really a thing on stock Android. Perhaps this will help. https://source.android.com/security/bulletin/2021-06-01

alexanderadam commented 3 years ago

Hm, now I'm also running into this. When I had a similar issue the last time I was asked by the system which file manager to use (I have Material File installed). But now the system doesn't ask.

Any idea how to enforce this?

J-Jamet commented 3 years ago

It is possible that an application is set as default to "OPEN_DOCUMENT" intent. It must be possible to change it in the settings of your device but I do not know where.

clemdumo commented 3 years ago

Hi guys, I thought I'd chime in. For a few days I've had a similar issue :

So I'm not sure KeepassDX is the culprit here but any pointers or thoughts could help.

I'm using KeepassDX Pro 2.10.5 on a Pixel 5 with Stock Android and the default file manager. Of course I can add details I might not have thought of if you need.

J-Jamet commented 3 years ago

I tried to improve the URI permission detection system in version 3.0.0. You will tell me if it is better for you or not when it is in beta.

alexanderadam commented 3 years ago

Can I install the beta from F-Droid?

J-Jamet commented 3 years ago

No, at the moment I haven't even finished the development. The beta will be on the Play Store. Otherwise it is possible to compile the source code.

clemdumo commented 3 years ago

I tried to improve the URI permission detection system in version 3.0.0. You will tell me if it is better for you or not when it is in beta.

Cheers, I'm looking forward to downloading the beta once it's out :) I'll make do with the current situation in the meantime, it's only a minor hassle.

J-Jamet commented 3 years ago

Also don't expect broken links to work on their own again if the file manager doesn't want, but I think it will solve a bug where some users had to go back to the database list to reset the link validity in the login screen.

J-Jamet commented 3 years ago

3.0.0_beta01 is out

clemdumo commented 3 years ago

Cheers. It just got pushed now and after testing relatively to the issue I described above :

— when entering selection mode from a field prompt, it would try to open the latest open database from an incorrect URI : now it sends me to the database selection screen, allowing me to pick which database to open which seems to prevent the error from occuring, the database loads as expected,

— when opening the app manually after having attempted to from a field prompt, the same error would occur but not it the app was manually open and the database correctly loaded the previous time : obviously that is fixed since the error doesn't happen ln the first place.

I don't know whether that was the intent, but that definitely works for me.

So well done thanks for that 👍🏻 👍🏻 👍🏻

auanasgheps commented 3 years ago

Hey, I have a related (maybe?) issue to the revoked file access. Still using the latest stable release.

When I open the app, sometimes, I can't see any DB at all, without any error message. However, If I force kill and then reopen the app, I'm prompted for the biometric unlock of my DB which opens and syncs fine. So in this case the access is not revoked by the file manager, but it's temporary lost by KPDX. I've seen this issue occurring a couple of times in the last few days but I have no idea how to replicate it.