Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactored access management #207

Merged
merged 93 commits into from
Aug 22, 2023
Merged

Conversation

overheadhunter
Copy link
Member

@overheadhunter overheadhunter commented Jul 6, 2023

This is the first part of a series of PRs, which simplify access management.

Introduction of User Key Pairs

We formerly only had Device Key Pairs. Vault keys have been shared with devices directly. This meant that the Vault Owner who is in possession of the vault keys had to re-run the key distribution (via the "Update Permissions") button, every time a new device required access to the vault.

Now, we added User Key Pairs. Vault keys are now shared with the user. Each user will self-manage his or her devices. The device key pair does still exist and is required to decrypt the user's private key.

Updated Entity Model

ERM

Unlock Procedure

Due to the introduction of an intermediary key, an unlock operation requires to

  1. first load the encrypted vault key (which can be decrypted using the user's private key) from /api/vaults/{vaultId}/access-token (response body is a ECDH-ES JWE)
  2. then load the encrypted private key of the user (which can be decrypted using the device's private key) from /api/devices/{deviceId} (response body contains a JSON. attribute userPrivateKey contains ECDH-ES JWE)

Unlock Workflow

We still keep the legacy API endpoint (/api/vaults/{vaultId}/keys/{deviceId}) for compatibility reasons for a while. However it will only work for existing data. Any newly registered device can only be unlocked using the new workflow.

Device Management

On the profile page, users can see their own devices. In order to add a new device, a Setup Code (here called "Personal Hub Secret", tbd) is required. This code is a secret required to unwrap the user's private key in order to re-wrap it using the device's public key. Once the device is set up, its private key will allow to access the user's private key.

The Setup Code can be access and changed any time by any fully set up device.

Device List

This fixes #189

First Device

The browser used to log in to Hub is now also considered a device and a Device Key Pair is generated and stored by the browser as well. The user will be prompted to name the browser accordingly (for identifying the browser, if they decide to revoke access from it later).

Initial Setup

The first device from which a login succeeds will also be responsible for generating the User Key Pair together with the Setup Code.

The user's private key is then encrypted in JWE format with a) the device's public key (using an ECDH-ES) and b) using the setup code (using PBES2). The setup code in return is encrypted as an JWE using the user's private key (ECDH-ES again). This ensures that any authenticated device has access to the user's key pair and can thus decrypt the setup code again. Also, the setup code can be used to decrypt the user's key pair when setting up a new device.

Vault Ownership

We used to use the Vault Admin Password to protect a vault from being edited by anyone. Instead we will now use role-based permissions. The creator of a vault is the initial owner. Further owners can be added at a later time. Any owner has full administrative access to a vault (e.g. for adding members).

The Vault Admin Password will be removed in a follow-up PR (as this one is already bursting).

Vault List

Other

  • Device.publicKey is now base64-encoded (used to be base64url for some reason)
  • Device.user_privateKey is now non-null, i.e. if a device exists, we can be sure it is able to access the user's key pair

Open Questions

  • Currently, we generate v4 UUID (i.e. 122 bit randomness) as a Setup Code, which is less than the key it protects. In my opinion this is sufficient, this setup code is then fed into PBKDF2 (currently defaulting to 1 mio iterations) to derive the key used to wrap the user's private key.

Next Steps

overheadhunter and others added 30 commits April 27, 2023 14:30
/api/vaults/{vaultId}/user-tokens/me
/api/users/me/device-tokens/{deviceId}
(so a device can be registered at t0 and verified at t1)
If a field must not be null, use @NotNull additionally. The one must not imply the other.
it doesn't work yet but it's probably close
[build image]
# Conflicts:
#	backend/src/main/java/org/cryptomator/hub/api/VaultResource.java
#	frontend/src/common/backend.ts
#	frontend/src/components/VaultList.vue
#	frontend/src/i18n/de-DE.json
#	frontend/src/i18n/en-US.json
…ration with version 11` after merging from develop
# Conflicts:
#	backend/src/main/java/org/cryptomator/hub/api/VaultResource.java
#	backend/src/test/java/org/cryptomator/hub/api/VaultResourceTest.java
#	backend/src/test/resources/org/cryptomator/hub/flyway/V9999__Test_Data.sql
#	frontend/src/common/backend.ts
# Conflicts:
#	backend/src/main/java/org/cryptomator/hub/api/AuditLogResource.java
#	backend/src/main/java/org/cryptomator/hub/api/VaultResource.java
overheadhunter and others added 5 commits August 2, 2023 09:05
# Conflicts:
#	frontend/src/common/jwe.ts
#	frontend/test/common/jwe.spec.ts
# Conflicts:
#	backend/src/main/java/org/cryptomator/hub/api/AuditLogResource.java
#	backend/src/main/java/org/cryptomator/hub/api/VaultResource.java
#	backend/src/test/java/org/cryptomator/hub/api/VaultResourceTest.java
#	frontend/src/common/backend.ts
#	frontend/src/components/VaultDetails.vue
#	frontend/src/i18n/en-US.json
@overheadhunter overheadhunter merged commit 465138a into develop Aug 22, 2023
@overheadhunter overheadhunter deleted the feature/refactored-access-grant branch January 27, 2024 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Self-Manage Devices
4 participants