Skip to content

After unlocking the keychain while Cryptomator is running, no option to use keychain features #1308

Closed

Description

@BeyerMart

Description

After fixing the Gnome keyring freeze by updating to secret-service. v1.1.0 in this commit it is possible to unlock a keychain even if you select cancel on the initial prompt to unlock your keychain.
After unlocking the keychain from somewhere else, it is not possible to access it from Cryptomator without restarting the app.

System Setup

  • Operating system and version: Lubuntu 19.10
  • Cryptomator version: post 1.5.7
  • Volume type: /

Steps to Reproduce

  1. Have a working keychain set as default on your system
  2. Start Cryptomator with the keychain locked
  3. Select "Cancel" in the first prompt before the application actually starts.
  4. Have a vault configured
  5. Go to a separate application (your keychain manager) and unlock the keychain

Expected Behavior

I can use the "fast" / "unlock now" feature.
When unlocking a vault without the password saved, the checkbox to save the password is there.
And in the vault options in the password tab, there is the "Forget Saved Password" option.

Actual Behavior

Cryptomator does not re-check if the system has a supportedKeychain and the keychain features are not usable.

Reproducibility

Always

Additional Information

Unlocked keychain, but no keychain features:
image

Activity

  1. changed the title [-]After unlocking the keychain while Cryptomator is running, no option to "fast" unlock[/-] [+]After unlocking the keychain while Cryptomator is running, no option to use keychain features[/+] on Aug 19, 2020
  2. added this to the 1.5.8 milestone on Aug 20, 2020
  3. modified the milestones: 1.5.8, 1.5.9 on Aug 27, 2020
  4. purejava commented on Aug 29, 2020

    @purejava
    Contributor

    Why doesn't it offer to use the keyring?

    Creating a SimpleCollection tries to unlock the default collection and in case it stays locked, isSupported() returns false.

    Since this test is only performed once during initialization, the keyring functionality stays disabled.

    https://github.com/purejava/secret-service/blob/e13b5397cbfef0eed8f5376df34e7532b227c41f/src/main/java/org/freedesktop/secret/simple/SimpleCollection.java#L47-L60

    public SimpleCollection() throws IOException {
        try {
            init();
    
            ObjectPath path = Static.Convert.toObjectPath(Static.ObjectPaths.DEFAULT_COLLECTION);
            this.collection = new Collection(path, service);
            unlock();
            if (this.collection.isLocked())
                throw new IOException("Could not communicate properly with the secret-service.");
        } catch (RuntimeException e) {
            log.error(e.toString(), e.getCause());
            throw new IOException(e.toString(), e.getCause());
        }
    }

    @Override
    public boolean isSupported() {
    try (@SuppressWarnings("unused") SimpleCollection keyring = new SimpleCollection()) {
    // seems like we're able to access the keyring.
    return true;
    } catch (IOException | RuntimeException e) {
    return false;
    }
    }

    The following would be one possible way to solve this, but this would require some secret-service interface design changes.
    A way to solve this would be a static method in SimpleCollection that checks whether a D-Bus object like Service is available on the bus. The way to do this would be via connection.getRemoteObject, similar to this:

    @Override
    public boolean isEnabled() {
        try {
            connection.getRemoteObject("org.kde.kwalletd5",
                    "/modules/kwalletd5", KWallet.class);
            log.info("Kwallet daemon is available.");
            return true;
        } catch (DBusException e) {
            log.error(e.toString(), e.getCause());
            return false;
        }
    }

    This would offer to check whether gnome-keyring is installed and configured (and subsequently return true for isSupported()).

    As there seem to be enough calls to unlock a keyring in the secret-service code, this would solve this issue.

  5. purejava commented on Aug 30, 2020

    @purejava
    Contributor

    @swiesend and I made the changes described above. They are commited to swiesend/secret-service develop-1.0.0.

    I tested Cryptomator 1.5.8 with develop-1.0.0 and it does solve this issue as the gnome-keyring functionality stays available.

    Maybe @BeyerMart has a chance to test it too? 😀

  6. swiesend commented on Sep 6, 2020

    @swiesend
    Contributor

    I made further changes and uploaded a 1.2.0-SNAPSHOT which lives on the current develop-1.0.0 branch as @purejava pointed out.

    The update mainly introduces the static isAvailable() method on the SimpleCollection. See the CHANGELOG.md and the open PR for 1.2.0 for all changes.

    But I could observe some non fatal issues with the 1.2.0-SNAPSHOT version:

    1. Sometimes there is a broken pipe DBusConnection - broken pipe
    2. Sometimes there is a problem with the message handling of dbus-java DBusConnection - RejectedExecutionException

    I guess I don't handle the close()/disconnect() in the new isAvailable() method well or introduced these issues with my further fixes of the SignalHandler.

    Feel free to test the version. I would appreciate some feedback on the integration, as I wasn't able to reproduce the initial KDE problem (#1268) with my virtual machine. Neither on 18.04 nor on 20.04.

  7. swiesend commented on Sep 10, 2020

    @swiesend
    Contributor

    I released a new 1.2.0-SNAPSHOT, which does not require explicit user permission by prompting for updating a collection item. I also tested the version with the current cryptomator master branch and it seems to be fine. The two mentioned issues occur like 1/50 and 1/25 times, but should be handled all time.

  8. purejava commented on Sep 12, 2020

    @purejava
    Contributor

    But I could observe some non fatal issues with the 1.2.0-SNAPSHOT version:

    1. Sometimes there is a broken pipe DBusConnection - broken pipe
    2. Sometimes there is a problem with the message handling of dbus-java DBusConnection - RejectedExecutionException

    So theses two issues only occur on shutting down? Did I get this right?

  9. purejava commented on Sep 12, 2020

    @purejava
    Contributor

    I released a new 1.2.0-SNAPSHOT, which does not require explicit user permission by prompting for updating a collection item. I also tested the version with the current cryptomator master branch and it seems to be fine. The two mentioned issues occur like 1/50 and 1/25 times, but should be handled all time.

    I compiled Cryptomator 1.5.8 with the 1.2.0-SNAPSHOT and I was also not able to trigger the two issues mentioned above.

  10. purejava commented on Sep 12, 2020

    @purejava
    Contributor

    If someone else is interested in testing there is a ready-to-go branch: purejava/cryptomator 1.2.0-SNAPSHOT.

  11. swiesend commented on Sep 17, 2020

    @swiesend
    Contributor

    So theses two issues only occur on shutting down? Did I get this right?

    yes on disconnect()s, but as I reuse now the initial connection this really should only occur on shutdown.

    I released this now as 1.2.0. See CHANGELOG.md.

  12. BeyerMart commented on Sep 18, 2020

    @BeyerMart
    Author
  13. purejava commented on Sep 18, 2020

    @purejava
  14. overheadhunter commented on Sep 21, 2020

    @overheadhunter
  15. infeo commented on Oct 30, 2020

    @infeo
    Member

    I tested this under the newest Ubuntu 20.10 and it works quite well. Especially, now at the application start i'm not always bugged by the question if I wanna open the keychain.

    Regarding the two stack traces at the end: Do they have any security implications? @swiesend I don't know the DBUS system good enough to make any guesses, and all i can see that either there might be some unclosed connection or unused signal handler.

  16. swiesend commented on Nov 1, 2020

    @swiesend
    Contributor

    From my point of view @infeo there are no further security implications apart form the typical disclaimer for D-Bus messaging in general and for the Secret Service API in specific (CVE-2018-19358) as the transport encryption of the connection is valid per session.

    I think this is whats happening for the two mentioned issues:

    1. DBusConnection - broken pipe swiesend/secret-service#20 can occur, when a signal handler (one registered per singal kind) was removed yet, but the open connection still receives a signal of that kind, which it then does not know how to handle properly. And meanwhile the connection closes and further signal handlers can't remove themselves anymore.
    2. DBusConnection - RejectedExecutionException swiesend/secret-service#21 seems to be the other way around: When the D-Bus connection is already closed, but a some singal handler still tries to remove itself.

    Both cases need more attention from my side (as the thread pool handling seems to be fine in java-dbus). So that the secret-service library will await still expected but not yet occurred signals (in a reasonable time frame), before removing the signal handlers and then closing the D-Bus connection.

    In the latest version 1.2.1 I fixed a bug, regarding the handling of the master secret for non-default collections (when connecting to an already existent non-default collection the user shouldn't be prompted as the master secret was already provided through the constructor). But as Cryptomator is just using the default collection that won't have any effect on your side.

  17. BeyerMart commented on Nov 9, 2020

    @BeyerMart
    ContributorAuthor

    Yeah, I also finally found some time to test this. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions