keepass2android icon indicating copy to clipboard operation
keepass2android copied to clipboard

[BUG] WebDAV authentication suddenly stopped working

Open larsskj opened this issue 2 years ago • 2 comments

Checks

  • [X] I have read the FAQ section, searched the open issues, and still think this is a new bug.

Describe the bug you encountered:

keepass2android suddenly stopped working on my phone today. Otherwise, I've been using it for quite many years without issues.

I run a setup with an Apache2 driven WebDAV server with public access from the Internet, and I use a mixture of clients to access the database. Primarily the classic KeePass .Net based client on Windows and Linux, and keepass2android on my phones.

I has been working fine for many years, but today keepass2android stopped working after I restarted the WebDAV server - or maybe not, it just happened to stop working around that time. Last time I used it was yesterday where it worked as expected.

The classic KeePass client works fine on Windows as well as Linux, and on the phone I can access and download the KeePass database using the various browsers I have on the phone. No problem.

But on keepass2android I get a 401 Unauthorized error and the Apache2 log file shows the same error.

I have tried rebooting the phone, force stopping the app, reloading the file as a new database - but to no avail: keepass2android won't authenticate unlike all other clients.

How do I troubleshoot this?

Describe what you expected to happen:

That keepass2android continues to load my database from the WebDAV server like it has been doing for years.

What version of Keepass2Android are you using?

1.09e-r7

Which version of Android are you on?

9

larsskj avatar Jun 24 '23 17:06 larsskj

The server restart sounds suspiciously related. I don't have much experience with WebDAV, but a few follow-up questions/thoughts:

  1. Do you happen to know if the KP2A app on your phone has been updated recently? 1.09e-r7 looks to have been pushed out the Google Play back in April. If it was a problem with the new version I would expect it to fail as soon as it was updated.
  2. Is the server running using HTTPS (hopefully)? If so, are you sure that it is still running using HTTPS after the restart?
  3. Is there any service in front of the server (e.g. a reverse-proxy like nginx or similar)?
  4. Are the other (working) clients also using HTTPS, and is there any indication that they could be downgrading to HTTP?
  5. Do you know which authentication type is being used (basic or digest), and has that possibly changed? (KP2A appears to implement both, from what I can tell, but just covering bases). Same question for the clients that are still working.

As for debugging:

  1. You could try to enable the Debug Log in KP2A (under Settings->App->Log-File for Debugging). I'm not sure how much, if any, useful info there will be there, but it's worth a try.
  2. Do you have access to the Apache2 server logs and/or have the ability to enable more logging there? Assuming there isn't some other service in-between that's replying with HTTP 401, that means Apache2 is seeing the request, and more verbose/debug logging there might be helpful (also a comparison between a working client session versus the failed KP2A session might reveal something).
  3. As a test, would it be possible to create a different user account on the server, and then try to connect to it using KP2A (and with the other clients)? That could indicate whether it's a user-specific issue or a server one.

hyproman avatar Jun 26 '23 23:06 hyproman

2024-03-05 01:52:40.686344+01:00[Tue Mar 05 00:52:40.686298 2024] [auth_basic:error] [pid 14:tid 140263045437120] [client 192.168.1.1:41708] AH01617: user usernamehere: authentication failure for "/webdav/Database.kdbx": Password Mismatch

Using TrueNAS scale with the WebDAV plugin i tried to connect. Strange thing is it does connect tries to open the Database but only when i have to enter the password to unlock the Database i get An Error occured: Received unexpected response: Response{protocol=http/1.1, code=401, message=Unauthorized, url=https://192.168.1.2:4000/webdav/Database.kdbx} When i use CF File Explorer or Firefox on Android to type that exact same adress i can download the file and open it in KP2A.

Log from the App:

3/5/2024 1:00:07 AM:112 -- AppSettingsActivity.OnPause 22
3/5/2024 1:00:07 AM:128 -- PasswordActivity.OnStart 21
3/5/2024 1:00:07 AM:129 -- PasswordActivity.OnResume 21
3/5/2024 1:00:07 AM:129 --  DB null 21
3/5/2024 1:00:07 AM:129 -- starting: True, Finishing: False, _performingLoad: False
3/5/2024 1:00:07 AM:129 -- https://user:[email protected]:40000/webdav/Database.kdbx isCached = False
3/5/2024 1:00:07 AM:731 -- AppSettingsActivity.OnStop 22
3/5/2024 1:00:07 AM:732 -- AppSettingsActivity.OnDestroyTrue 22
3/5/2024 1:00:10 AM:687 -- PasswordActivity.OnPause 21
3/5/2024 1:00:10 AM:697 -- SelectCurrentDbActivity.OnStart 18
3/5/2024 1:00:10 AM:698 -- SelectCurrentDbActivity 18: OnActivityResult FirstUser/1
3/5/2024 1:00:10 AM:699 -- TryGetFromActivityResult: no data
3/5/2024 1:00:10 AM:706 -- SelectCurrentDbActivity.OnResume 18
3/5/2024 1:00:10 AM:706 --  DB null 18
3/5/2024 1:00:10 AM:706 -- SelectCurrentDbActivity.OnResume 18
3/5/2024 1:00:10 AM:706 --  DB null 18
3/5/2024 1:00:10 AM:718 -- SelectCurrentDbActivity.OnPause 18
3/5/2024 1:00:10 AM:726 -- FileSelect.OnCreate
3/5/2024 1:00:10 AM:734 -- FileSelect.OnStart
3/5/2024 1:00:10 AM:735 -- FileSelect.OnResume
3/5/2024 1:00:11 AM:328 -- PasswordActivity.OnStop 21
3/5/2024 1:00:11 AM:332 -- PasswordActivity.OnDestroyTrue 21
3/5/2024 1:00:11 AM:391 -- SelectCurrentDbActivity.OnStop 18
3/5/2024 1:00:13 AM:595 -- https://user:[email protected]:40000/webdav/Database.kdbx isCached = False
3/5/2024 1:00:13 AM:624 -- FileSelect.OnPause
3/5/2024 1:00:13 AM:630 -- PasswordActivity.OnCreate 23
3/5/2024 1:00:13 AM:630 -- PasswordActivity:apptask= 23
3/5/2024 1:00:13 AM:644 -- GetIocFromLaunchIntent()
3/5/2024 1:00:13 AM:644 -- no keyprovider specified
3/5/2024 1:00:13 AM:644 -- Reset keyfile
3/5/2024 1:00:13 AM:646 -- PasswordActivity.OnStart 23
3/5/2024 1:00:13 AM:646 -- PasswordActivity.OnResume 23
3/5/2024 1:00:13 AM:647 --  DB null 23
3/5/2024 1:00:13 AM:647 -- starting: True, Finishing: False, _performingLoad: False
3/5/2024 1:00:13 AM:647 -- https://user:[email protected]:40000/webdav/Database.kdbx isCached = False
3/5/2024 1:00:13 AM:647 -- Pre-loading database file starting
3/5/2024 1:00:13 AM:648 -- https://user:[email protected]:40000/webdav/Database.kdbx isCached = False
3/5/2024 1:00:13 AM:648 -- CFS: OpenWhenNoLocalChanges
3/5/2024 1:00:13 AM:675 -- PasswordModeSpinner item selected: 0
3/5/2024 1:00:13 AM:765 -- Received unexpected response: Response{protocol=http/1.1, code=401, message=Unauthorized, url=https://192.168.1.2:40000/webdav/Database.kdbx}
3/5/2024 1:00:13 AM:766 -- https://user:[email protected]:40000/webdav/Database.kdbx isCached = False
3/5/2024 1:00:14 AM:215 -- FileSelect.OnStop
3/5/2024 1:00:14 AM:273 -- FileSelect.OnDestroyTrue
3/5/2024 1:00:22 AM:418 -- https://user:[email protected]:40000/webdav/Database.kdbx isCached = False
3/5/2024 1:00:22 AM:420 -- LockingActivity: OnActivityResult 
3/5/2024 1:00:22 AM:421 -- PasswordActivity.OnActivityResult 874348/1000
3/5/2024 1:00:22 AM:435 -- status message: Initializing...
3/5/2024 1:00:22 AM:436 -- status submessage: 
3/5/2024 1:00:22 AM:457 -- status message: Loading database…
3/5/2024 1:00:22 AM:458 -- System.Exception: Received unexpected response: Response{protocol=http/1.1, code=401, message=Unauthorized, url=https://192.168.1.2:40000/webdav/Database.kdbx} ---> Java.Lang.Exception: Received unexpected response: Response{protocol=http/1.1, code=401, message=Unauthorized, url=https://192.168.1.2:40000/webdav/Database.kdbx}
  at Java.Interop.JniEnvironment+InstanceMethods.CallObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x0006e] in <6fb1725a77344b3e81b15cb69a959b5c>:0 
  at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0003c] in <6fb1725a77344b3e81b15cb69a959b5c>:0 
  at Keepass2android.Javafilestorage.WebDavStorage.OpenFileForRead (System.String path) [0x00029] in <8c6bb6e6ee5d44ad91d9ee9c1a43f965>:0 
  at keepass2android.Io.JavaFileStorage.OpenFileForRead (KeePassLib.Serialization.IOConnectionInfo ioc) [0x0000d] in <4387dcce18dd490eadd43a838bbc0f3d>:0 
   --- End of inner exception stack trace ---
  at keepass2android.Io.JavaFileStorage.OpenFileForRead (KeePassLib.Serialization.IOConnectionInfo ioc) [0x0002b] in <4387dcce18dd490eadd43a838bbc0f3d>:0 
  at keepass2android.Io.OfflineSwitchableFileStorage.OpenFileForRead (KeePassLib.Serialization.IOConnectionInfo ioc) [0x00006] in <4387dcce18dd490eadd43a838bbc0f3d>:0 
  at keepass2android.Io.CachingFileStorage.UpdateCacheFromRemote (KeePassLib.Serialization.IOConnectionInfo ioc, System.String cachedFilePath) [0x00000] in <4387dcce18dd490eadd43a838bbc0f3d>:0 
  at keepass2android.Io.CachingFileStorage.OpenFileForReadWhenNoLocalChanges (KeePassLib.Serialization.IOConnectionInfo ioc, System.String cachedFilePath) [0x00023] in <4387dcce18dd490eadd43a838bbc0f3d>:0 
  at keepass2android.Io.CachingFileStorage.OpenFileForRead (KeePassLib.Serialization.IOConnectionInfo ioc) [0x0005a] in <4387dcce18dd490eadd43a838bbc0f3d>:0 
  at keepass2android.PasswordActivity.PreloadDbFile () [0x0004c] in <dabeaecbf9c0465bb1ce8a7bcc561766>:0 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <3deb12e7bedf4d1bb8b41d6af3450e05>:0 
  at System.Threading.Tasks.Task.Execute () [0x00000] in <3deb12e7bedf4d1bb8b41d6af3450e05>:0 
3/5/2024 1:03:02 AM:324 -- PasswordActivity.OnPause 23
3/5/2024 1:03:02 AM:416 -- PasswordActivity.OnStop 23
3/5/2024 1:03:03 AM:470 -- PasswordActivity.OnStart 23
3/5/2024 1:03:03 AM:471 -- PasswordActivity.OnResume 23
3/5/2024 1:03:03 AM:471 --  DB null 23
3/5/2024 1:03:03 AM:472 -- starting: True, Finishing: False, _performingLoad: False
3/5/2024 1:03:03 AM:473 -- https://user:[email protected]:40000/webdav/Database.kdbx isCached = False
3/5/2024 1:03:03 AM:476 -- Pre-loading database file starting
3/5/2024 1:03:03 AM:476 -- https://user:[email protected]:40000/webdav/Database.kdbx isCached = False
3/5/2024 1:03:03 AM:476 -- CFS: OpenWhenNoLocalChanges
3/5/2024 1:03:03 AM:550 -- Received unexpected response: Response{protocol=http/1.1, code=401, message=Unauthorized, url=https://192.168.1.2:40000/webdav/Database.kdbx}
3/5/2024 1:03:03 AM:550 -- https://user:[email protected]:40000/webdav/Database.kdbx isCached = False
3/5/2024 1:03:12 AM:749 -- PasswordActivity.OnPause 23
3/5/2024 1:03:12 AM:767 -- AppSettingsActivity.OnCreate 24
3/5/2024 1:03:12 AM:767 -- AppSettingsActivity:apptask= 24
3/5/2024 1:03:12 AM:785 -- AppSettingsActivity.OnStart 24
3/5/2024 1:03:12 AM:786 -- AppSettingsActivity.OnResume 24
3/5/2024 1:03:12 AM:786 --  DB null 24
3/5/2024 1:03:13 AM:339 -- PasswordActivity.OnStop 23
3/5/2024 1:03:14 AM:12 -- AppSettingsActivity.OnPause 24
3/5/2024 1:03:14 AM:628 -- AppSettingsActivity.OnStop 24
3/5/2024 1:03:15 AM:94 -- AppSettingsActivity.OnStart 24
3/5/2024 1:03:15 AM:96 -- AppSettingsActivity.OnResume 24
3/5/2024 1:03:15 AM:96 --  DB null 24
3/5/2024 1:03:17 AM:823 -- AppSettingsActivity.OnPause 24
3/5/2024 1:03:23 AM:759 -- AppSettingsActivity.OnResume 24
3/5/2024 1:03:23 AM:759 --  DB null 24
3/5/2024 1:03:25 AM:751 -- AppSettingsActivity.OnPause 24
3/5/2024 1:03:25 AM:807 -- SelectCurrentDbActivity.OnDestroyTrue 18
3/5/2024 1:03:25 AM:815 -- PasswordActivity.OnDestroyTrue 23
3/5/2024 1:03:26 AM:205 -- AppSettingsActivity.OnStop 24
3/5/2024 1:05:05 AM:665 -- AppSettingsActivity.OnStart 24
3/5/2024 1:05:05 AM:665 -- AppSettingsActivity.OnResume 24
3/5/2024 1:05:05 AM:665 --  DB null 24

FML i found the issue -.-

Don't use Passwords that include äöü !

haldi4803 avatar Mar 05 '24 01:03 haldi4803