strongbox-password-safe / Strongbox

A KeePass/Password Safe Client for iOS and OS X
https://strongboxsafe.com
GNU Affero General Public License v3.0
1.34k stars 102 forks source link

Autofill Crashes #99

Closed rob3c closed 5 years ago

rob3c commented 5 years ago

Hi, i just ended my trial early and registered both the iOS and macOS versions, as I'm super happy with everything so far - thanks!

My issue is regarding iOS autofill using a keepass db. Let's say i try to log into github. The keyboard shows an entry is available and prompts me to use the right one. I click it, then go through the TouchID prompt. Then it shows a spinner, and then just returns to the login page without entering anything in either the user or pw fields. It just continues to show an entry an available, but the cycle will just repeat without success if i keep trying. I'm logged into the db in a separate strongbox app window while doing this. The db is in readonly mode.

I know there's a faq entry about autofill crashing due to apple resource limitations, but I thought some issues i read suggested it should work now. Also, I have a friend who uses 1password with a database with at least 3+ times as many entries as mine, and his works just fine.

So, should mine be working now and this is an unexpected crash, or are there still expected crashes due to apple constraints combined with certain keepass db characteristics?

If it's really resource limitations set by apple, where are those documented? How is 1password likely working within them successfully for similar functionality? I miss my keepass keyboard on android, and autofill seems like the best alternative on iOS, given custom keyboard limitations.

georgesnow commented 5 years ago

Jsut thinking how do you have your database stored? iCloud sftp etc

JLWFuQrioea69ugsykvQcg commented 5 years ago

FWIW Autofill and QuickType work great for me on all of my devices. I have over 1,000 entries in my Keepass2 database. On very rare occasions, I go through the Autofill process and Strongbox fails to fill the username/password fields so I have to try it again, but it’s not enough to be an issue. I haven’t taken the time to see if I could reliably reproduce the issue. I have a database I imported/copied into Strongbox and another that’s opened directly from OneDrive—both work fine.

How big is your database—size and entry count? What Keepass program was used to create it—Keepass, Macpass, KeePassXC, etc? What type of ciphers are you using? Where and how is your database being hosted?

mmcguill commented 5 years ago

Hi @rob3c Thanks for the support! Yes, this is very likely the resource limitation.

There is a limit of roughly 100-120MB memory that Apple imposes, which is also device dependent, there doesn't seem to be a solid source of documentation on this unfortunately. If you're using Argon2, make sure the memory is lower than say 96MB, preferrably 64MB or so. There is also a limit on CPU consumption.

Can I ask what your crypto settings are? Argon2? What size is your database (file size) roughly? Also, if you have any crash dumps, if you could send them over, I'll take a look at what's happening...

Feel free to send me an email if that's preferable (support@strongboxsafe.com).

There is still some work on improving Strongbox's memory footprint in the long run which will help to.

Ctarley commented 5 years ago

Hi, everyone. I've the same issue: i installed first time StrongBox (iOS) and KeePassXC (Ubuntu) a few days ago, and then faced with this problem. DB was created in KeePassXC, then it was filled 19 entries, and transfered to StrongBox.

@mmcguill I leave it here, to ease searches affected users. iOS Version: 12.2 (16E227) App Version: 1.26.1

DB Format: KeePass 2 KeePass File Version: 4.0 Database Generator: KeePassXC Key Derivation: Argon2 Outer Encryption: AES Compressed: Yes (GZIP) Inner Encryption: ChaCha20

DB size: 4.1 kB DB entries: 19

georgesnow commented 5 years ago

I am really curious how you storing and accessing your database? cause i have got in the ballpark 300 entries and i haven't had this issue.

Ctarley commented 5 years ago

Well, as for me I've copied database from laptop via USB-cable, and then just imported in StrongBox. I store it locally without syncing in iCloud. By the way, I'm accessing to it by keyfile & password. animation

mmcguill commented 5 years ago

Hi @Ctarley, do you have any crash logs on your device?

Also, could you try running "Maintenance" in the Original KeePass application to remove "Deleted Objects" and trim your "History". Does that help? I've had reports this can help, and would be keen to know if helps you.

You can find crash logs by:

Navigate to your device Settings > Privacy > Analytics > Analytics Data.
Scroll through this list to find 'Strongbox' events. The list is alphabetical. 
Tap one of these events. 
Tap the share icon at the top right, and if you could, email me support@strongboxsafe.com

Thanks, -Mark

JLWFuQrioea69ugsykvQcg commented 5 years ago

I’ve experienced a similar issue on occasion where I open Strongbox from the browsers keyboard, select the entry in Strongbox, and it returns to the login screen but doesn’t type anything. I’ll redo the action and it usually works the second time. Unfortunately it’s not consistent or specific to any entry so hard to reproduce it manually. I don’t have any crash logs either.

Ctarley commented 5 years ago

I've updated to 1.27.2, and trying to unlock database, caught it:

So at this moment I've remembered, that when I created DB, I'd set manually 128 MB for mem usage. Now I changed it to 64 MB, and everything is OK. Thank you!

mmcguill commented 5 years ago

Cool! Nice to see that message is working out there in the real world :)

@rob3c how are you getting on with the App? Is this an issue we can close do you think?

mmcguill commented 5 years ago

@rob3c Closing this soon due to inactivity. Let me know if you're still having issues... -Mark

rob3c commented 5 years ago

@mmcguill Hi Mark, thanks for pinging me about this! You all apparently replied very quickly, but it got lost in the blur of the past several weeks. (Sorry everyone!)

Unfortunately, no. I haven't been able to get it to work. It pops up regularly, but nothing ever populates - it just crashes(?) back to the input box after touch ID. I'm stuck using the clipboard. It's possible it is something in my setup, which I'm willing to try to change if it'll help - especially updating to more recent KP format(s)/settings lol. Here are current settings:

sbox-summary

Right now, it's synced via dropbox, but due to their free acct policy changes and my move to iOS, I'll likely be switching soon.

iOS settings set to ON: Allow Touch ID Unlock, Use 'QuickType' AutoFill, Allow AutoFill Cache, Allow Offline Cache

UPDATE: I wanted to add that it fails the same way on both my ipad and iphone, so it doesn't seem to be device-specific.

mmcguill commented 5 years ago

No worries and thanks for getting back to me @rob3c

Could you tell me the file size of your DB please?

rob3c commented 5 years ago

Sure @mmcguill, the file size is 7.2MB.

mmcguill commented 5 years ago

Thanks @rob3c - I need to do some investigation on the sizes that crash - I thought it was above 14MB but this one is much lower.

Could you try running Database Maintenance in the original Windows KeePass app is you have access to it? There you can trim History and importantly Cleanup 'Deleted Objects' if you have a minute?

ghost commented 5 years ago

Here same problem. I go to https://mail.protonmail.com/login. I see in the iOS keyboard my logins. Tap on iOS 12 autofill function. Confirm password. But it's not working.

iPad Air 2 iOS Version: 12.4.1 App Version: 1.40.0

DB Format: KeePass 2 KeePass File Version: 4.0 Database Generator: Strongbox Key Derivation: Argon2 Outer Encryption: ChaCha20 Compressed: Yes Inner Encryption: ChaCha20

DB size: 17.1 mb DB entries: 350

With Enpass app and same entries no problem. Here I use Safari extension under iOS share button. If use iOS autofill function also no problem. I like the extension function more, because you don't see the logins data in the keyboard immediately. but only after unlocking or entering the password.

mmcguill commented 5 years ago

Thanks for the extra datapoint @iOS6martinaa - This will almost certainly be down to the absolute size of your DB (17.1 MB)... But just in case, can you tell me the Memory parameter you are using with Argon2?

ghost commented 5 years ago

This will almost certainly be down to the absolute size of your DB (17.1 MB) I don't think so. I saved some documents and pictures there (all about 13 mb in size)

But just in case, can you tell me the Memory parameter you are using with Argon2? 1 MB

DB was created in KeePassXC 2.5.0 https://snapshot.keepassxc.org/build-36976/

Use import "1Password vault" from KeePassXC 2.5.0 and transfered to Strongbox iOS. Ghen a few entries deleted with Strongebox iOS version. Done.

mmcguill commented 5 years ago

Yeah, at the moment performance isn't great on these large DBs, I'm working to improve it and hopefully will have something much better in the next release.

17.1MB is compressed size, expanded you could be looking at 2-8x (from my own experiments). This needs to be handled better in AutoFill because auto fill is severely memory limited...

Thanks for all your input, I'll work on getting some of those fixes in

mmcguill commented 5 years ago

Hi @rob3c - Things should be much improved now with 1.42.0 - Could you check it out and see if it fixes the crashing issue?

JLWFuQrioea69ugsykvQcg commented 5 years ago

Autofill is working much more consistently now.

mmcguill commented 5 years ago

Believe a lot of these issues should be fixed now with the performance improvements added. Going to close this one off

rob3c commented 5 years ago

@mmcguill Thanks for finally solving this!!! It now works for the first time ever with the same database that had all of the earlier problems. It's a wonderful feature, and it improves the overall experience tremendously.

asheshambasta commented 4 years ago

This doesn't seem solved for me. I have a 35kB database shared via Dropbox that consistently causes Strongbox to crash on each auto-fill attempt. I tried providing the crash logs but there are no strongbox events in the crash logs.

The thing is that auto-fill has never worked for me. It just consistently crashes every time I try to use it.

strongbox-mark commented 4 years ago

Hi @asheshambasta - Sounds like you've got a very interesting database there...

Do you know if you are using Argon2 for your KDF? And if so, do you know your Argon2 memory setting?

You can find out by opening your database in the main Strongbox app > Preferences (Gear icon in the bottom left) > Statistics & Properties > Database Properties > Key Derivation/Argon2 Memory.

If not, could you try creating a new database in the main app and seeing if you can open that in AutoFill ok?

asheshambasta commented 4 years ago

image

That's the screenshot for my current settings. I'll try with a new database and report back.

asheshambasta commented 4 years ago

No crashes on the new database with just one entry. I created this database with the express settings on Strongbox itself.

image

strongbox-mark commented 4 years ago

Yes, ok, that'll explain things. Your Argon2 memory setting there will immediately blow the allotted quota of the AutoFill process.

To fix this crash, you would need to reduce that to about 32MB or lower (You can compensate for this by increasing CPU if you feel necessary).

This however cannot be done in Strongbox at the moment, you would need to use KeePassXC or KeePass.

asheshambasta commented 4 years ago

@strongbox-mark okay; thanks for taking the time to clarify this. Can this be done on an existing database? I am using KeepassXC on my desktop but I cannot see the params. on the DB settings.

strongbox-mark commented 4 years ago

Yes, for sure can be done on an existing database.

On the Mac the setting in KeePassXC is: Database > Database Settings > Security > Encryption Settings > Memory Usage

image

Should be fairly similar on Windows

asheshambasta commented 4 years ago

Yeah; this doesn't seem to be present on Linux; image At least not on KeePassXC 2.5.4.

strongbox-mark commented 4 years ago

Tap the "Advanced Settings" checkbox in the bottom left?

rob3c commented 4 years ago

Since this thread has been revived, I thought I'd follow up and mention that autofill has generally been working well for me (yay!), but it did eventually start crashing periodically for whatever reason (I don't remember which update I originally associated the crashing with). I'd guess it happens now maybe once every couple weeks, and that's with using it multiple times a day across an iphone and an ipad.

However, it seems that Strongbox detects the crashing now and manages to recover most of the time, rather than just silently failing back to the input like it did before. It's nothing that I think needs to be specifically addressed for my usage - I'm just passing along another data point in case it's helpful.

Anyway, thanks again for fixing it!

strongbox-mark commented 4 years ago

@rob3c - thanks for the update...

@asheshambasta - any luck?

asheshambasta commented 4 years ago

@strongbox-mark thanks for following up; and yeah, I can confirm that the settings you suggested work quite well. I have 32MB set; and so far I have no complaints. Thanks so much for suggesting this.

Mr-Sheep commented 4 years ago

I have set to 32mb, and it worked for a while. But now having the same problem again 9582EE90-087B-41A5-8608-DBDB98C933FB

Model: iPad
CPU: ARM64E
System Name: iOS
System Version: 14.0
Ep: 1600240510
Flags: F[1[90]101[8]1101]
App Version: com.markmcguill.strongbox [1.49.20 (2961)@d67fd8a]
JSON Crash:
Databases Collection
----------------
Passwords-2 1 (Sync) => 2020-09-17 14:46:53.986 (232 KB)
{
    auditConfig =     {
        auditInBackground = 1;
        caseInsensitiveMatchForDuplicates = 1;
        checkForCommonPasswords = 1;
        checkForDuplicatedPasswords = 1;
        checkForMinimumLength = 0;
        checkForNoPasswords = 0;
        checkForSimilarPasswords = 0;
        checkHibp = 0;
        hibpCaveatAccepted = 0;
        hibpCheckForNewBreachesIntervalSeconds = 86400;
        lastKnownAuditIssueCount = 353;
        levenshteinSimilarityThreshold = "0.75";
        minimumLength = 12;
        showAuditPopupNotifications = 1;
        showCachedHibpHits = 1;
    };
    autoFillEnabled = 1;
    autoLockTimeoutSeconds = 60;
    browseItemSubtitleField = 1;
    browseSortField = 1;
    browseSortFoldersSeparately = 1;
    browseSortOrderDescending = 0;
    browseViewType = 0;
    colorizePasswords = 1;
    colorizeProtectedCustomFields = 0;
    detailsViewCollapsedSections =     (
        0,
        0,
        0,
        0,
        1,
        1
    );
    doNotShowRecycleBinInBrowse = 0;
    doubleTapAction = 4;
    duressAction = 0;
    easyReadFontForAll = 0;
    failedPinAttempts = 0;
    fileIdentifier = "file:///private/var/mobile/Library/Mobile%20Documents/iCloud~com~strongbox/Documents/Passwords-2%201.kdbx";
    fileName = "Passwords-2 1.kdbx";
    hasBeenPromptedForConvenience = 1;
    hasBeenPromptedForQuickLaunch = 1;
    hasUnresolvedConflicts = 0;
    hideIconInBrowse = 0;
    hideTotp = 0;
    hideTotpCustomFieldsInViewMode = 1;
    hideTotpInBrowse = 0;
    immediateSearchOnBrowse = 0;
    isEnrolledForConvenience = 1;
    isTouchIdEnabled = 1;
    keePassIconSet = 1;
    keyFileBookmark = "<redacted>";
    lastSyncRemoteModDate = "622018013.9862516";
    likelyFormat = 2;
    longPressTapAction = 3;
    makeBackups = 1;
    maxBackupKeepCount = 10;
    nickName = "Passwords-2 1";
    promptedForAutoFetchFavIcon = 0;
    readOnly = 0;
    searchDereferencedFields = 1;
    showChildCountOnFolderInBrowse = 1;
    showEmptyFieldsInDetailsView = 0;
    showExpiredInBrowse = 1;
    showExpiredInSearch = 1;
    showFlagsInBrowse = 1;
    showKeePass1BackupGroup = 0;
    showPasswordByDefaultOnEditScreen = 0;
    showQuickViewExpired = 0;
    showQuickViewFavourites = 1;
    showQuickViewNearlyExpired = 1;
    showRecycleBinInSearchResults = 0;
    storageProvider = 3;
    tapAction = 1;
    tripleTapAction = 8;
    tryDownloadFavIconForNewRecord = 1;
    uuid = "56759C70-6E8E-4E13-BEA7-4774256C5F5F";
    viewDereferencedFields = 1;
}----------------

Argon2 analysis page below C6546CBA-5590-441D-A338-436ED613B965

strongbox-mark commented 4 years ago

Hi @Mr-Sheep - Does setting your Argon2 memory to 8MB help?

Does this happen always or only when adding a new entry?

Mr-Sheep commented 4 years ago

Hi @Mr-Sheep - Does setting your Argon2 memory to 8MB help?

Does this happen always or only when adding a new entry?

I’ll give 8mb a try. It happens every time when trying to use auto filling

Mr-Sheep commented 4 years ago

@strongbox-mark 8mb doesn’t help 029EBE52-21B0-427A-92E0-D3DFB16C7895

strongbox-mark commented 4 years ago

Thanks @Mr-Sheep - Could I ask what are your Transform Rounds? It's possible your CPU usage is killing the process instead of memory. A sample database looks like this:

image

Could you send similar from KeePassXC/KeePass for your database?

Mr-Sheep commented 4 years ago

Screenshot from 2020-09-19 00-24-52 Screenshot from 2020-09-19 00-31-01

@strongbox-mark thanks for helping I've already tried some, no luck

strongbox-mark commented 4 years ago

Hi @Mr-Sheep,

Couple of things to try:

  1. Set memory, transform rounds and parallelism to 1 - Does that help?
  2. How about if you change the Encryption Algorithm to TwoFish or ChaCha20?
  3. Could you tell me if this happens just on opening/read-only or if it happens only when you add a new entry?

Also... Remember you will need to go to the main app to sync these changes before reopening in AutoFill mode. Pull down to refresh and note the Modified Date should have changed.

Mr-Sheep commented 4 years ago

Umm, it’s odd I removed my key file and everything works fine Probably it’s due to a large key file (roughly 30 mb)

strongbox-mark commented 4 years ago

That is a super interesting edge case I hadn't considered. Reading and digesting that file would at the moment probably be enough to overrun the memory limit.

This is something that could be improved actually. I'll add it to the tech debt backlog.

Thank you for your patience and investigation efforts.

Mr-Sheep commented 4 years ago

No problem.

FYI, here’s my current db config 670AB168-DF23-4152-9AA4-7CD7299C0B1C And I’ve tested key file with size up to 27.5 mb

strongbox-mark commented 4 years ago

Cheers!

MichiFr commented 1 year ago

Any progress on this issue. Seeing this from time to time on iPadOS 16.4.x, too. Databse size is 4.24 MB with 213 groups, 2253 accounts with notes and attachments. Password databse was created with Keepass2 on Windows.

Argon2 size is set to 4MB.

Michael

strongbox-mark commented 1 year ago

Hi @MichiFr - No news here, this is a very difficult problem to solve given the constraints of the iOS App Extension system.

Unfortunately, the best current solution is to archive off any unused accounts/attachments you can and reduce database size, in terms of file size but also number of entries.