Rookiestyle / KeePassOTP

Add OTP support (two factor authentication) to KeePass
GNU General Public License v3.0
405 stars 29 forks source link

Error/Crash on Start with latest version #78

Closed electronicm closed 3 years ago

electronicm commented 3 years ago

Overview

Steps to Reproduce

  1. Install version 1.1 of this Plugin
  2. Start Keepass
  3. Open DB

Expected Behavior

It should not cause an error

Actual Behavior

As soon as a database is loaded and unlocked, Keepass issues an error message indicating this plugin.

Context

OS: Win10 20H2 Pro KeePass Version: 2.49 Plugin Version: 1.1

************** Ausnahmetext **************
System.ArgumentException: "[PATH TO DB REMOVED]" wird analysiert - Unbekannte Escape-Zeichenfolge \K.
   bei System.Text.RegularExpressions.RegexParser.ScanCharEscape()
   bei System.Text.RegularExpressions.RegexParser.ScanBasicBackslash()
   bei System.Text.RegularExpressions.RegexParser.ScanRegex()
   bei System.Text.RegularExpressions.RegexParser.Parse(String re, RegexOptions op)
   bei System.Text.RegularExpressions.Regex..ctor(String pattern, RegexOptions options, TimeSpan matchTimeout, Boolean useCache)
   bei System.Text.RegularExpressions.Regex..ctor(String pattern)
   bei KeePassOTP.TFASites.<IsTFAPossible>b__2(String sRegex, String sUrl)
   bei KeePassOTP.TFASites.<>c__DisplayClass7.<IsTFAPossible>b__3(KeyValuePair`2 x)
   bei System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   bei KeePassOTP.TFASites.IsTFAPossible(String url)
   bei KeePassOTP.KeePassOTPColumnProvider.GetCellData(String strColumnName, PwEntry pe)
   bei KeePass.UI.ColumnProviderPool.GetCellData(String strColumnName, PwEntry pe)
   bei KeePass.Forms.MainForm.GetEntryFieldEx(PwEntry pe, Int32 iColumnID, Boolean bFormatForDisplay, Boolean& bRequestAsync)
   bei KeePass.Forms.MainForm.SetListEntry(PwEntry pe, ListViewItem lviTarget)
   bei KeePass.Forms.MainForm.UpdateEntryList(PwGroup pgSelected, Boolean bOnlyUpdateCurrentlyShown)
   bei KeePass.Forms.MainForm.UpdateUI(Boolean bRecreateTabBar, PwDocument dsSelect, Boolean bUpdateGroupList, PwGroup pgSelect, Boolean bUpdateEntryList, PwGroup pgEntrySource, Boolean bSetModified, Control cOptFocus)
   bei KeePass.Forms.MainForm.OnGroupsNodeClick(Object sender, TreeNodeMouseClickEventArgs e)
   bei System.Windows.Forms.TreeView.OnNodeMouseClick(TreeNodeMouseClickEventArgs e)
   bei System.Windows.Forms.TreeView.WmNotify(Message& m)
   bei System.Windows.Forms.TreeView.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Geladene Assemblys **************
mscorlib
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4360.0 built by: NET48REL1LAST_C.
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll.
----------------------------------------
KeePass
    Assembly-Version: 2.49.0.17016.
    Win32-Version: 2.49.0.0.
    CodeBase: file:///C:/Program%20Files/KeePass%20Password%20Safe%202/KeePass.exe.
----------------------------------------
System
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4360.0 built by: NET48REL1LAST_C.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll.
----------------------------------------
System.Windows.Forms
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4341.0 built by: NET48REL1LAST_C.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll.
----------------------------------------
System.Drawing
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll.
----------------------------------------
System.Configuration
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4190.0 built by: NET48REL1LAST_B.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll.
----------------------------------------
System.Core
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4360.0 built by: NET48REL1LAST_C.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll.
----------------------------------------
System.Xml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll.
----------------------------------------
System.Windows.Forms.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.Windows.Forms.resources.dll.
----------------------------------------
Accessibility
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Accessibility/v4.0_4.0.0.0__b03f5f7f11d50a3a/Accessibility.dll.
----------------------------------------
HaveIBeenPwnedPlugin
    Assembly-Version: 0.7.0.0.
    Win32-Version: 0.7.1.1.
    CodeBase: file:///C:/Program%20Files/KeePass%20Password%20Safe%202/Plugins/HaveIBeenPwnedPlugin.dll.
----------------------------------------
System.Net.Http
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Net.Http/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Net.Http.dll.
----------------------------------------
KeePassOTP
    Assembly-Version: 1.1.0.0.
    Win32-Version: 1.1.
    CodeBase: file:///C:/Users/Raiko/AppData/Local/KeePass/PluginCache/yMAHAP4LyGQntk1DAnB2/KeePassOTP.dll.
----------------------------------------
Newtonsoft.Json
    Assembly-Version: 13.0.0.0.
    Win32-Version: 13.0.1.25517.
    CodeBase: file:///C:/Users/Raiko/AppData/Local/KeePass/PluginCache/yMAHAP4LyGQntk1DAnB2/Newtonsoft.Json.DLL.
----------------------------------------
KeePassRPC
    Assembly-Version: 2.0.34.31092.
    Win32-Version: 1.14.0.0.
    CodeBase: file:///C:/Users/Raiko/AppData/Local/KeePass/PluginCache/hKZ7e9RVxYgMx7De50KJ/KeePassRPC.dll.
----------------------------------------
Fleck2
    Assembly-Version: 1.0.0.0.
    Win32-Version: 1.0.0.0.
    CodeBase: file:///C:/Users/Raiko/AppData/Local/KeePass/PluginCache/hKZ7e9RVxYgMx7De50KJ/Fleck2.DLL.
----------------------------------------
DomainPublicSuffix
    Assembly-Version: 2.0.1.0.
    Win32-Version: 2.0.1.0.
    CodeBase: file:///C:/Users/Raiko/AppData/Local/KeePass/PluginCache/hKZ7e9RVxYgMx7De50KJ/DomainPublicSuffix.DLL.
----------------------------------------
Jayrock
    Assembly-Version: 0.9.12915.0.
    Win32-Version: 0.9.11214.1056.
    CodeBase: file:///C:/Users/Raiko/AppData/Local/KeePass/PluginCache/hKZ7e9RVxYgMx7De50KJ/Jayrock.DLL.
----------------------------------------
KeeTheme
    Assembly-Version: 0.9.2.0.
    Win32-Version: 0.9.2.0.
    CodeBase: file:///C:/Users/Raiko/AppData/Local/KeePass/PluginCache/LWuAy8qb8iclTb9Xa0Gr/KeeTheme.dll.
----------------------------------------
YetAnotherFaviconDownloader
    Assembly-Version: 1.2.4.0.
    Win32-Version: 1.2.4.0.
    CodeBase: file:///C:/Users/Raiko/AppData/Local/KeePass/PluginCache/WpJoyomXZyDWygioopIQ/YetAnotherFaviconDownloader.dll.
----------------------------------------
KeePass.XmlSerializers
    Assembly-Version: 2.49.0.17016.
    Win32-Version: 2.49.0.17016.
    CodeBase: file:///C:/Program%20Files/KeePass%20Password%20Safe%202/KeePass.XmlSerializers.DLL.
----------------------------------------
System.Security
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4261.0 built by: NET48REL1LAST_B.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Security/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Security.dll.
----------------------------------------
mscorlib.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/mscorlib.resources/v4.0_4.0.0.0_de_b77a5c561934e089/mscorlib.resources.dll.
----------------------------------------
System.Data.SqlXml
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.SqlXml/v4.0_4.0.0.0__b77a5c561934e089/System.Data.SqlXml.dll.
----------------------------------------
protobuf-net
    Assembly-Version: 2.4.0.0.
    Win32-Version: 2.4.6.0.
    CodeBase: file:///C:/Users/Raiko/AppData/Local/KeePass/PluginCache/yMAHAP4LyGQntk1DAnB2/protobuf-net.DLL.
----------------------------------------
Jayrock.Json
    Assembly-Version: 0.9.12915.0.
    Win32-Version: 0.9.13422.2206.
    CodeBase: file:///C:/Users/Raiko/AppData/Local/KeePass/PluginCache/hKZ7e9RVxYgMx7De50KJ/Jayrock.Json.DLL.
----------------------------------------
System.Runtime.Serialization
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4250.0 built by: NET48REL1LAST_C.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Runtime.Serialization/v4.0_4.0.0.0__b77a5c561934e089/System.Runtime.Serialization.dll.
----------------------------------------
System.Numerics
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Numerics/v4.0_4.0.0.0__b77a5c561934e089/System.Numerics.dll.
----------------------------------------
Microsoft.GeneratedCode
    Assembly-Version: 1.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll.
----------------------------------------
System.Data
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4270.0 built by: NET48REL1LAST_C.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_64/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll.
----------------------------------------
System.resources
    Assembly-Version: 4.0.0.0.
    Win32-Version: 4.8.4084.0 built by: NET48REL1.
    CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.resources/v4.0_4.0.0.0_de_b77a5c561934e089/System.resources.dll.
----------------------------------------

This did not occur with previous versions.

Debug_KeePassOTP_20211113T135345Z.xml.txt

Rookiestyle commented 3 years ago

KeePassOTP 1.1.0.1.zip

Unfortunately the debug file does not provide any further details.

Please try the attached version. It will not fix the bug but it will show the values of sRegex and sUrl mentioned in the dump

KeePassOTP.TFASites.b__2(String sRegex, String sUrl)

electronicm commented 3 years ago

[EDIT]

I have looked at the log file again. For each tag listed, there is a % before the "escape string".These are from environment variables in the database path. \O = ...%someVar%\Osometext.... \K = ...%someVar%\Ksometext...

With this version a lot of error dialog boxes appeared, but after that Keepass works normally.

Rookiestyle commented 3 years ago

"[PATH TO DB REMOVED]" wird analysiert - Unbekannte Escape-Zeichenfolge \K. [PATH TO DB REMOVED] https://[URL FROM ENTRY REMOVED]

I really would need to know the value of [PATH TO DB REMOVED] and whether it's different or the same in all of the messages - if you prefer, you can send it per mail (rookiestyle gmx net) If it's different values, 2-3 of them would be great to know.

This should not be the path to your db but a different url - retrieved from https://2fa.directory/api/v3/tfa.json - and should look like ^https?://(.+\.|)amazon\.com You didn't change KeePassOTP.TFASiteCheckURL in your KeePass config file, did you?

Is %someVar%\Ksometext part of [PATH TO DB REMOVED] or Part of https://[URL FROM ENTRY REMOVED] or both?

jschwoer commented 3 years ago

I am observing the same issue with the error message "Unbekannte Escape-Zeichenfolge \F".

In my case the URL points to a network share in the form "\\server.domain\path\to\directory\". (Please note that this is not the real URL stored in the KeePass entry). The real entry begins with "\f".

Rookiestyle commented 3 years ago

This helped and I'm working on a fix.

jschwoer commented 3 years ago

Works for me with release 1.1.1. Thanks for this very fast fix!