Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add email claim transfer signing

Leendert de Borst38a69fde979b
diff --git a/apps/browser-extension/src/entrypoints/background.ts b/apps/browser-extension/src/entrypoints/background.ts
index 06f44cad8..0e62ba956 100644
--- a/apps/browser-extension/src/entrypoints/background.ts
+++ b/apps/browser-extension/src/entrypoints/background.ts
@@ -13,7 +13,7 @@ import { handleGetWebAuthnSettings, handleWebAuthnCreate, handleWebAuthnGet, han
import { handleOpenPopup, handlePopupWithItem, handleOpenPopupCreateCredential, handleToggleContextMenu } from '@/entrypoints/background/PopupMessageHandler';
import { handleStoreSavePromptState, handleGetSavePromptState, handleClearSavePromptState, handleGetLastAutofilled, handleClearLastAutofilled } from '@/entrypoints/background/SavePromptStateHandler';
import { handleGetTwoFactorPrompt, handleClearTwoFactorState } from '@/entrypoints/background/TwoFactorStateHandler';
-import { handleCheckAuthStatus, handleClearPersistedFormValues, handleClearSession, handleClearVaultData, handleLockVault, handleGetFilteredItems, handleGetSearchItems, handleGetEncryptionKey, handleGetUnlockKeyDerivationParams, handleGetPersistedFormValues, handleGetVaultMigrationStatus, handlePersistFormValues, handleStoreAccountKey, handleStoreUnlockKeyDerivationParams, handleStoreEncryptedVaultChunk, handleGetSyncState, handleMigrateVaultManifest, handleFullVaultSync, handleGroupCreateVault, handleGroupInviteMember, handleGroupUpdateVault, handleGroupLookupAccountFingerprint, handleGroupInviteMemberByFingerprint, handleGroupAcceptManifestInvitation, handleCheckLoginDuplicate, handleSaveLoginCredential, handleAddUrlToCredential, handleIsUrlLinkedToCredential, handleGetLoginSaveSettings, handleGetItemsWithTotp, handleSearchItemsWithTotp, handleGetTotpCodes, handleGenerateTotpCode, handleGetAutofillCredential, handleRecordItemUsage, type AutofillSender } from '@/entrypoints/background/VaultMessageHandler';
+import { handleCheckAuthStatus, handleClearPersistedFormValues, handleClearSession, handleClearVaultData, handleLockVault, handleGetFilteredItems, handleGetSearchItems, handleGetEncryptionKey, handleGetUnlockKeyDerivationParams, handleGetPersistedFormValues, handleGetVaultMigrationStatus, handlePersistFormValues, handleStoreAccountKey, handleStoreUnlockKeyDerivationParams, handleStoreEncryptedVaultChunk, handleGetSyncState, handleMigrateVaultManifest, handleFullVaultSync, handleGroupCreateVault, handleGroupInviteMember, handleGroupUpdateVault, handleGroupLookupAccountFingerprint, handleGroupInviteMemberByFingerprint, handleGroupAcceptManifestInvitation, handleEmailClaimTransfer, handleCheckLoginDuplicate, handleSaveLoginCredential, handleAddUrlToCredential, handleIsUrlLinkedToCredential, handleGetLoginSaveSettings, handleGetItemsWithTotp, handleSearchItemsWithTotp, handleGetTotpCodes, handleGenerateTotpCode, handleGetAutofillCredential, handleRecordItemUsage, type AutofillSender } from '@/entrypoints/background/VaultMessageHandler';
import { getCurrentAutofillFrameUrl } from '@/entrypoints/contentScript/AutofillFrameUrl';
import { logFailure } from '@/utils/Diagnostics';
@@ -319,6 +319,7 @@ export default defineBackground({
onExtensionPageMessage('GROUP_LOOKUP_ACCOUNT_FINGERPRINT', ({ data }) => handleGroupLookupAccountFingerprint(data));
onExtensionPageMessage('GROUP_INVITE_MEMBER_BY_FINGERPRINT', ({ data }) => handleGroupInviteMemberByFingerprint(data));
onExtensionPageMessage('GROUP_ACCEPT_MANIFEST_INVITATION', ({ data }) => handleGroupAcceptManifestInvitation(data));
+ onExtensionPageMessage('EMAIL_CLAIM_TRANSFER', ({ data }) => handleEmailClaimTransfer(data));
onExtensionPageMessage('LOCK_VAULT', () => handleLockVault());
onExtensionPageMessage('CLEAR_SESSION', () => handleClearSession());
onExtensionPageMessage('CLEAR_VAULT_DATA', () => handleClearVaultData());
diff --git a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
index 5150d3847..b28643365 100644
--- a/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
+++ b/apps/browser-extension/src/entrypoints/background/VaultMessageHandler.ts
@@ -19,7 +19,7 @@ import { clearDirtyScopes, getDirtyScopes } from '@aliasvault/client/sync/VaultD
import { vaultRequiresManifestMigration, VaultMigrationKind } from '@aliasvault/client/sync/VaultManifestMigration';
import { type VaultMutationScope, DEFAULT_VAULT_MUTATION_SCOPE, hasUserVisibleScope } from '@aliasvault/client/sync/VaultMutationScope';
import { hasSyncError, syncResult, VaultSync, type FullVaultSyncResult, type SharedManifestDetails, type SharingOperationResult, type VaultManifestMigrationResult } from '@aliasvault/client/sync/VaultSync';
-import { type IVaultSyncEngineHost, type VaultSyncOptions, type VaultSyncPhase as EngineSyncPhase, type VaultSyncStoreOutcome, type VaultSyncStoreRequest } from '@aliasvault/client/sync/VaultSyncEngine';
+import { type EmailClaimTransfer, type IVaultSyncEngineHost, type VaultSyncOptions, type VaultSyncPhase as EngineSyncPhase, type VaultSyncStoreOutcome, type VaultSyncStoreRequest } from '@aliasvault/client/sync/VaultSyncEngine';
import { getVaultSyncHoldReason } from '@aliasvault/client/sync/VaultSyncHold';
import { FieldKey, ItemTypes, createSystemField, getFieldValue, itemToCredential, normalizeTotpPeriod, type Credential, type Item } from '@aliasvault/models/vault';
@@ -1553,3 +1553,12 @@ export async function handleGroupAcceptManifestInvitation(message: { invitationI
return sharingActionResponse(result, sharingText.errors.invitationGone);
}
+/**
+ * Move an email alias to another manifest, signed with this account's own key.
+ *
+ * @param message - the alias, its current and new manifest, and the claim version the mailbox reported.
+ */
+export async function handleEmailClaimTransfer(message: EmailClaimTransfer): Promise<SharingActionResponse> {
+ return sharingActionResponse(await vaultSync.transferEmailClaim(message), await t('common.errors.unknownErrorTryAgain'));
+}
+
diff --git a/apps/browser-extension/src/entrypoints/popup/components/EmailPreview.tsx b/apps/browser-extension/src/entrypoints/popup/components/EmailPreview.tsx
index 9b56b27cc..a3ab5de7b 100644
--- a/apps/browser-extension/src/entrypoints/popup/components/EmailPreview.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/components/EmailPreview.tsx
@@ -1,5 +1,4 @@
-import { apiErrorCodeOf } from '@aliasvault/client/api/errors/ApiRequestError';
-import { type AliasOwnerNotice, aliasOwnerErrorText, aliasOwnerNotice, moveAliasHere } from '@aliasvault/client/email/AliasOwner';
+import { type AliasOwnerNotice, aliasOwnerErrorText, aliasOwnerNotice } from '@aliasvault/client/email/AliasOwner';
import { decryptEmailList } from '@aliasvault/client/email/EmailDecryption';
import { SpamOkClient } from '@aliasvault/client/email/SpamOkClient';
import { AppInfo } from '@aliasvault/client/platform/AppInfo';
@@ -17,6 +16,7 @@ import { useWebApi } from '@/entrypoints/popup/context/WebApiContext';
import { StorageKeys } from '@/utils/constants/storageKeys';
import { logExpected } from '@/utils/Diagnostics';
+import { sendMessage } from '@/utils/messaging/ExtensionMessaging';
import type { ApiErrorResponse, Mailbox, MailboxEmail } from '@aliasvault/models/webapi';
@@ -256,19 +256,22 @@ export const EmailPreview: React.FC<EmailPreviewProps> = ({ email, manifestId })
*/
const moveHere = async (): Promise<void> => {
setShowMoveConfirm(false);
- try {
- await moveAliasHere(webApi, email, manifestId);
- setOwnerNotice(null);
- setLoading(true);
- } catch (err) {
- setError(aliasOwnerErrorText(apiErrorCodeOf(err)) ?? t('apiErrors.' + apiErrorCodeOf(err), { defaultValue: t('common.errors.unknownErrorTryAgain') }));
+ if (!ownerNotice?.transfer) {
+ return;
}
+ const result = await sendMessage('EMAIL_CLAIM_TRANSFER', ownerNotice.transfer);
+ if (!result.success) {
+ setError(aliasOwnerErrorText(result.apiErrorCode) ?? (result.apiErrorCode ? t('apiErrors.' + result.apiErrorCode, { defaultValue: t('common.errors.unknownErrorTryAgain') }) : result.error ?? t('common.errors.unknownErrorTryAgain')));
+ return;
+ }
+ setOwnerNotice(null);
+ setLoading(true);
};
const ownerNoticeBlock = ownerNotice && (
<div className="mb-2 p-3 bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/40 rounded">
<p className="text-sm text-amber-900 dark:text-amber-100">{ownerNotice.notice}</p>
- {ownerNotice.canMove && (
+ {ownerNotice.transfer && (
<button
id="move-alias-here"
onClick={() => setShowMoveConfirm(true)}
diff --git a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
index 7b94982b4..3ced24fd5 100644
--- a/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
+++ b/apps/browser-extension/src/utils/messaging/ExtensionMessaging.ts
@@ -34,6 +34,7 @@ import type { ItemRef } from '@aliasvault/client/database/ItemRef';
import type { VaultMigrationKind } from '@aliasvault/client/sync/VaultManifestMigration';
import type { VaultMutationScope } from '@aliasvault/client/sync/VaultMutationScope';
import type { FullVaultSyncResult, SharedManifestDetails, VaultManifestMigrationResult } from '@aliasvault/client/sync/VaultSync';
+import type { EmailClaimTransfer } from '@aliasvault/client/sync/VaultSyncEngine';
import type { UnlockKeyDerivationParams } from '@aliasvault/models/metadata';
import type { Credential } from '@aliasvault/models/vault';
@@ -104,6 +105,7 @@ export interface IExtensionMessageProtocol {
GROUP_LOOKUP_ACCOUNT_FINGERPRINT(data: { groupId?: string; accountFingerprint: string }): SharingActionResponse;
GROUP_INVITE_MEMBER_BY_FINGERPRINT(data: { groupId: string; manifestId: string; accountFingerprint: string }): SharingActionResponse;
GROUP_ACCEPT_MANIFEST_INVITATION(data: { invitationId: string; accountFingerprint?: string }): SharingActionResponse;
+ EMAIL_CLAIM_TRANSFER(data: EmailClaimTransfer): SharingActionResponse;
IS_URL_LINKED_TO_CREDENTIAL(data: { itemId: string; manifestId: string; url: string }): { linked: boolean };
IS_LOGIN_SAVE_BLOCKED(data: { domain: string }): boolean;
LOCK_VAULT(): BoolResponse;
diff --git a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSync.kt b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSync.kt
index c292aca56..86e91354d 100644
--- a/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSync.kt
+++ b/apps/mobile-app/android/app/src/main/java/net/aliasvault/app/vaultstore/VaultSync.kt
@@ -37,6 +37,7 @@ class VaultSync(
"updateSharedManifest",
"lookupAccountFingerprint",
"acceptSharedManifestInvitation",
+ "transferEmailClaim",
)
}
diff --git a/apps/mobile-app/components/items/details/EmailPreview.tsx b/apps/mobile-app/components/items/details/EmailPreview.tsx
index 27702ed19..11d115a56 100644
--- a/apps/mobile-app/components/items/details/EmailPreview.tsx
+++ b/apps/mobile-app/components/items/details/EmailPreview.tsx
@@ -4,13 +4,13 @@ import React, { useState, useEffect, useCallback, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { View, StyleSheet, TouchableOpacity, Linking, AppState } from 'react-native';
-import { apiErrorCodeOf } from '@aliasvault/client/api/errors/ApiRequestError';
-import { type AliasOwnerNotice, aliasOwnerErrorText, aliasOwnerNotice, moveAliasHere } from '@aliasvault/client/email/AliasOwner';
+import { type AliasOwnerNotice, aliasOwnerErrorText, aliasOwnerNotice } from '@aliasvault/client/email/AliasOwner';
import { SpamOkClient } from '@aliasvault/client/email/SpamOkClient';
import { sharingText } from '@aliasvault/client/sharing/SharingView';
import { AppInfo } from '@aliasvault/client/platform/AppInfo';
import { logExpected } from '@aliasvault/client/utilities/Diagnostics';
import { mailboxPollDelayMs } from '@aliasvault/client/utilities/PollBackoff';
+import type { EmailClaimTransfer } from '@aliasvault/client/sync/VaultSyncEngine';
import type { ApiErrorResponse, Mailbox, MailboxEmail } from '@aliasvault/models/webapi';
import { decryptEmailList } from '@aliasvault/client/email/EmailDecryption';
@@ -22,6 +22,7 @@ import { ThemedView } from '@/components/themed/ThemedView';
import { useDb } from '@/context/DbContext';
import { useDialog } from '@/context/DialogContext';
import { useWebApi } from '@/context/WebApiContext';
+import NativeVaultManager from '@/specs/NativeVaultManager';
/** Client for the SpamOK mailboxes of the public email domains. */
const spamOk = new SpamOkClient('av-mobile', AppInfo.VERSION);
@@ -384,23 +385,23 @@ export const EmailPreview: React.FC<EmailPreviewProps> = ({ email, manifestId })
/**
* Move the alias to this item's vault after confirmation, then reload.
*/
- const confirmMoveHere = (moveConfirm: string): void => {
+ const confirmMoveHere = (transfer: EmailClaimTransfer, moveConfirm: string): void => {
showConfirm(sharingText.aliasOwner.moveHere, moveConfirm, t('common.confirm'), async () => {
- try {
- await moveAliasHere(webApi, email, manifestId);
- setOwnerNotice(null);
- setLoading(true);
- } catch (err) {
- setError(aliasOwnerErrorText(apiErrorCodeOf(err)) ?? t(`apiErrors.${apiErrorCodeOf(err)}`, { defaultValue: t('common.errors.unknownErrorTryAgain') }));
+ const result = await NativeVaultManager.runSharingOperation('transferEmailClaim', JSON.stringify(transfer));
+ if (!result.success) {
+ setError(aliasOwnerErrorText(result.apiErrorCode) ?? t(`apiErrors.${result.apiErrorCode}`, { defaultValue: t('common.errors.unknownErrorTryAgain') }));
+ return;
}
+ setOwnerNotice(null);
+ setLoading(true);
});
};
const ownerNoticeBlock = ownerNotice && (
<View style={styles.ownerNotice}>
<ThemedText style={styles.ownerNoticeText}>{ownerNotice.notice}</ThemedText>
- {ownerNotice.canMove && (
- <TouchableOpacity style={styles.moveButton} onPress={() => confirmMoveHere(ownerNotice.moveConfirm)} testID="move-alias-here">
+ {ownerNotice.transfer && (
+ <TouchableOpacity style={styles.moveButton} onPress={() => confirmMoveHere(ownerNotice.transfer!, ownerNotice.moveConfirm)} testID="move-alias-here">
<ThemedText style={styles.moveButtonText}>{sharingText.aliasOwner.moveHere}</ThemedText>
</TouchableOpacity>
)}
diff --git a/apps/mobile-app/ios/VaultStoreKit/Services/VaultSync.swift b/apps/mobile-app/ios/VaultStoreKit/Services/VaultSync.swift
index 50f15b05c..154db9266 100644
--- a/apps/mobile-app/ios/VaultStoreKit/Services/VaultSync.swift
+++ b/apps/mobile-app/ios/VaultStoreKit/Services/VaultSync.swift
@@ -237,7 +237,7 @@ internal final class VaultSync {
}
/// The engine operations the sharing screen may ask for.
- private static let sharingOperations: Set<String> = ["createSharedManifest", "inviteToSharedManifest", "updateSharedManifest", "lookupAccountFingerprint", "acceptSharedManifestInvitation"]
+ private static let sharingOperations: Set<String> = ["createSharedManifest", "inviteToSharedManifest", "updateSharedManifest", "lookupAccountFingerprint", "acceptSharedManifestInvitation", "transferEmailClaim"]
/// The forced logouts by the engine's reason.
private static let logoutErrors: [String: AppError] = [
diff --git a/apps/server/AliasVault.Api/Controllers/V2/Email/EmailBoxController.cs b/apps/server/AliasVault.Api/Controllers/V2/Email/EmailBoxController.cs
index 14f145618..f093a37ea 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/Email/EmailBoxController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/Email/EmailBoxController.cs
@@ -141,6 +141,7 @@ public class EmailBoxController(IAliasServerDbContextFactory dbContextFactory, U
// For now anyone who can open the owning manifest may move the alias, matching VaultController.TransferEmailClaim.
CanTransfer = true,
+ ClaimVersion = emailClaim.Version,
};
return Ok(returnValue);
diff --git a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
index 3fbd3b45f..c1e3c2bb0 100644
--- a/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
+++ b/apps/server/AliasVault.Api/Controllers/V2/VaultController.cs
@@ -742,7 +742,7 @@ public class VaultController(
/// <summary>
/// Moves an email alias to another manifest, which becomes its only owner. The caller must be able to open both the
- /// current owning manifest and the target.
+ /// current owning manifest and the target, and sign the move with their signing key, so a session token alone cannot redirect mail.
/// </summary>
/// <param name="model">The alias and the target manifest.</param>
/// <returns>Ok when the alias is owned by the target manifest.</returns>
@@ -776,6 +776,12 @@ public class VaultController(
return Ok();
}
+ var signingKey = await GrantHelper.GetPrimarySigningKeyAsync(context, user.Id);
+ if (signingKey is null || !Signing.Verify(signingKey, Signing.EmailClaimTransferMessage(address, model.SourceManifestId, model.TargetManifestId, model.ClaimVersion), model.Signature))
+ {
+ return ApiError.Result(ApiErrorCode.SIGNATURE_INVALID, 400);
+ }
+
var targetGroupId = (await GroupHelper.GetOwnerGroupsAsync(context, [model.TargetManifestId]))[model.TargetManifestId];
var strategy = context.Database.CreateExecutionStrategy();
@@ -785,7 +791,7 @@ public class VaultController(
await LockAliasQuotaGroupsAsync(context, [targetGroupId]);
await context.Entry(claim).ReloadAsync();
- if (claim.VaultManifestId != sourceManifestId)
+ if (claim.VaultManifestId != model.SourceManifestId || claim.Version != model.ClaimVersion)
{
return ApiError.Result(ApiErrorCode.EMAIL_CLAIM_MOVED, 409);
}
diff --git a/apps/server/Databases/AliasServerDb/EmailClaim.cs b/apps/server/Databases/AliasServerDb/EmailClaim.cs
index 21bbbbf9c..6abec9628 100644
--- a/apps/server/Databases/AliasServerDb/EmailClaim.cs
+++ b/apps/server/Databases/AliasServerDb/EmailClaim.cs
@@ -74,4 +74,11 @@ public class EmailClaim
/// Gets or sets updated timestamp.
/// </summary>
public DateTime UpdatedAt { get; set; }
+
+ /// <summary>
+ /// Gets the claim version a transfer is signed over: <see cref="UpdatedAt"/> in Unix milliseconds, so a signed transfer
+ /// stops verifying once the claim changed.
+ /// </summary>
+ [NotMapped]
+ public long Version => new DateTimeOffset(DateTime.SpecifyKind(UpdatedAt, DateTimeKind.Utc)).ToUnixTimeMilliseconds();
}
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Email/MailboxApiModel.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Email/MailboxApiModel.cs
index 1e3fa3d76..3782330c0 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Email/MailboxApiModel.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Email/MailboxApiModel.cs
@@ -39,6 +39,11 @@ public class MailboxApiModel
/// </summary>
public bool CanTransfer { get; set; }
+ /// <summary>
+ /// Gets or sets the version of the alias claim, which a transfer to another manifest is signed over.
+ /// </summary>
+ public long? ClaimVersion { get; set; }
+
/// <summary>
/// Gets or sets the list of mailbox email API models.
/// </summary>
diff --git a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/EmailClaimTransferRequest.cs b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/EmailClaimTransferRequest.cs
index 8e7291005..590c187c3 100644
--- a/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/EmailClaimTransferRequest.cs
+++ b/apps/server/Shared/AliasVault.Shared/Models/WebApi/V2/Vault/EmailClaimTransferRequest.cs
@@ -8,13 +8,22 @@
namespace AliasVault.Shared.Models.WebApi.V2.Vault;
/// <summary>
-/// Moves an email alias from its current owning manifest to another manifest.
+/// Moves an email alias from its current owning manifest to another manifest, signed by the caller.
/// </summary>
public class EmailClaimTransferRequest
{
/// <summary>Gets or sets the full email address of the alias.</summary>
public required string Address { get; set; }
+ /// <summary>Gets or sets the manifest that owns the alias before the move.</summary>
+ public required Guid SourceManifestId { get; set; }
+
/// <summary>Gets or sets the manifest that becomes the new owner of the alias.</summary>
public required Guid TargetManifestId { get; set; }
+
+ /// <summary>Gets or sets the claim version the client was served, which the signature covers.</summary>
+ public required long ClaimVersion { get; set; }
+
+ /// <summary>Gets or sets the caller's Ed25519 signature over the transfer (see <c>Signing.EmailClaimTransferMessage</c>).</summary>
+ public required string Signature { get; set; }
}
diff --git a/apps/server/Tests/AliasVault.UnitTests/Utilities/SigningTests.cs b/apps/server/Tests/AliasVault.UnitTests/Utilities/SigningTests.cs
index 354fc5ab9..c7ef5bfa4 100644
--- a/apps/server/Tests/AliasVault.UnitTests/Utilities/SigningTests.cs
+++ b/apps/server/Tests/AliasVault.UnitTests/Utilities/SigningTests.cs
@@ -39,4 +39,14 @@ public class SigningTests
var message = Signing.KeyCertificationMessage("user-1", "user-2", PublicKeyVector);
Assert.That(Convert.ToHexStringLower(message), Is.EqualTo("00000023616c6961737661756c742f76312f7369672f6b65792d63657274696669636174696f6e00000006757365722d3100000006757365722d320000002c41364548762f504f454c3464634e3059353076416d57666b316a436270513166486479475a424a564d62673d"));
}
+
+ /// <summary>
+ /// The email claim transfer message equals the Rust core's EMAIL_CLAIM_TRANSFER_MESSAGE_VECTOR.
+ /// </summary>
+ [Test]
+ public void EmailClaimTransferMessageKnownAnswer()
+ {
+ var message = Signing.EmailClaimTransferMessage("[email protected]", Guid.Parse("0A1B2C3D-0000-0000-0000-000000000001"), Guid.Parse("0A1B2C3D-0000-0000-0000-000000000002"), 1767225600000);
+ Assert.That(Convert.ToHexStringLower(message), Is.EqualTo("00000026616c6961737661756c742f76312f7369672f656d61696c2d636c61696d2d7472616e7366657200000011616c696173406578616d706c652e636f6d0000002430613162326333642d303030302d303030302d303030302d3030303030303030303030310000002430613162326333642d303030302d303030302d303030302d3030303030303030303030320000000d31373637323235363030303030"));
+ }
}
diff --git a/apps/server/Utilities/AliasVault.Cryptography/Signing.cs b/apps/server/Utilities/AliasVault.Cryptography/Signing.cs
index e4dd07055..d3cbea07f 100644
--- a/apps/server/Utilities/AliasVault.Cryptography/Signing.cs
+++ b/apps/server/Utilities/AliasVault.Cryptography/Signing.cs
@@ -37,6 +37,11 @@ public static class Signing
/// </summary>
public const string InvitationNameLabel = "aliasvault/v1/sig/invitation-name";
+ /// <summary>
+ /// The label of moving an email alias to another manifest, signed by the user who moves it.
+ /// </summary>
+ public const string EmailClaimTransferLabel = "aliasvault/v1/sig/email-claim-transfer";
+
/// <summary>
/// The label of a new signing public key, signed by the signing key it replaces.
/// </summary>
@@ -119,6 +124,19 @@ public static class Signing
return SignedMessage(DeliveryKeyLabel, Utf8(manifestId.ToString()), Utf8(publicKey), Utf8(currentRevision.ToString(System.Globalization.CultureInfo.InvariantCulture)));
}
+ /// <summary>
+ /// Builds the signed message of moving an email alias to another manifest, bound to the claim version so it cannot be replayed.
+ /// </summary>
+ /// <param name="address">The alias address, trimmed and lowercased.</param>
+ /// <param name="sourceManifestId">The manifest that owns the alias before the move.</param>
+ /// <param name="targetManifestId">The manifest that owns the alias after the move.</param>
+ /// <param name="claimVersion">The claim version the client was served.</param>
+ /// <returns>The message bytes.</returns>
+ public static byte[] EmailClaimTransferMessage(string address, Guid sourceManifestId, Guid targetManifestId, long claimVersion)
+ {
+ return SignedMessage(EmailClaimTransferLabel, Utf8(address), Utf8(sourceManifestId.ToString()), Utf8(targetManifestId.ToString()), Utf8(claimVersion.ToString(System.Globalization.CultureInfo.InvariantCulture)));
+ }
+
/// <summary>
/// Builds the signed message of a signing key rotation: the account's new signing public key, signed by the previous one.
/// </summary>
diff --git a/apps/web/src/components/email/RecentEmails.tsx b/apps/web/src/components/email/RecentEmails.tsx
index 51fc4b3d9..65bb11d3d 100644
--- a/apps/web/src/components/email/RecentEmails.tsx
+++ b/apps/web/src/components/email/RecentEmails.tsx
@@ -1,5 +1,5 @@
import { apiErrorCodeOf } from '@aliasvault/client/api/errors/ApiRequestError';
-import { type AliasOwnerNotice, aliasOwnerErrorText, aliasOwnerNotice, moveAliasHere } from '@aliasvault/client/email/AliasOwner';
+import { type AliasOwnerNotice, aliasOwnerErrorText, aliasOwnerNotice } from '@aliasvault/client/email/AliasOwner';
import { decryptEmailList } from '@aliasvault/client/email/EmailDecryption';
import { sharingText } from '@aliasvault/client/sharing/SharingView';
import React, { useCallback, useEffect, useRef, useState } from 'react';
@@ -19,6 +19,7 @@ import { useWebApi } from '@/context/WebApiContext';
import { useEmailDomains } from '@/hooks/useEmailDomains';
import { useMinDurationLoading } from '@/hooks/useMinDurationLoading';
import { type EmailViewModel, loadAliasVaultEmail, loadSpamOkEmail, spamOk } from '@/utils/EmailViewModel';
+import { vaultStore } from '@/vault/VaultStore';
import type { Mailbox, MailboxEmail } from '@aliasvault/models/webapi';
@@ -196,15 +197,15 @@ const RecentEmails: React.FC<RecentEmailsProps> = ({ emailAddress, manifestId })
* Move the alias to this item's vault after confirmation, then reload.
*/
const moveHere = async (): Promise<void> => {
- if (!ownerNotice || !await showConfirmation(sharingText.aliasOwner.moveHere, ownerNotice.moveConfirm, t('common.confirm'), t('common.cancel'))) {
+ if (!ownerNotice?.transfer || !await showConfirmation(sharingText.aliasOwner.moveHere, ownerNotice.moveConfirm, t('common.confirm'), t('common.cancel'))) {
return;
}
- try {
- await moveAliasHere(webApi, emailAddress, manifestId);
- await manualRefresh();
- } catch (err) {
- setError(aliasOwnerErrorText(apiErrorCodeOf(err)) ?? t('apiErrors.' + apiErrorCodeOf(err), { defaultValue: t('common.errors.unknownErrorTryAgain') }));
+ const result = await vaultStore.transferEmailClaim(ownerNotice.transfer);
+ if (!result.success) {
+ setError(aliasOwnerErrorText(result.apiErrorCode) ?? t('apiErrors.' + result.apiErrorCode, { defaultValue: t('common.errors.unknownErrorTryAgain') }));
+ return;
}
+ await manualRefresh();
};
if (!showComponent) {
@@ -240,7 +241,7 @@ const RecentEmails: React.FC<RecentEmailsProps> = ({ emailAddress, manifestId })
</div>
{!isLoading && error.length === 0 && ownerNotice && (
- <WarningBox className="mt-4" actions={ownerNotice.canMove && <Button id="move-alias-here" onClick={() => void moveHere()}>{sharingText.aliasOwner.moveHere}</Button>}>
+ <WarningBox className="mt-4" actions={ownerNotice.transfer && <Button id="move-alias-here" onClick={() => void moveHere()}>{sharingText.aliasOwner.moveHere}</Button>}>
<p>{ownerNotice.notice}</p>
</WarningBox>
)}
diff --git a/apps/web/src/vault/VaultStore.ts b/apps/web/src/vault/VaultStore.ts
index d9a0c955b..5fb274f83 100644
--- a/apps/web/src/vault/VaultStore.ts
+++ b/apps/web/src/vault/VaultStore.ts
@@ -11,7 +11,7 @@ import { clearDirtyScopes, getDirtyScopes } from '@aliasvault/client/sync/VaultD
import { vaultRequiresManifestMigration, VaultMigrationKind } from '@aliasvault/client/sync/VaultManifestMigration';
import { DEFAULT_VAULT_MUTATION_SCOPE, hasUserVisibleScope, type VaultMutationScope } from '@aliasvault/client/sync/VaultMutationScope';
import { hasSyncError, syncResult, VaultSync, type FullVaultSyncResult, type KeyRotationOperationResult, type SharedManifestDetails, type SharingOperationResult, type VaultManifestMigrationResult } from '@aliasvault/client/sync/VaultSync';
-import { type IVaultSyncEngineHost, type VaultSyncKeyRotationParams, type VaultSyncOptions, type VaultSyncPhase as EngineSyncPhase, type VaultSyncStoreOutcome, type VaultSyncStoreRequest } from '@aliasvault/client/sync/VaultSyncEngine';
+import { type EmailClaimTransfer, type IVaultSyncEngineHost, type VaultSyncKeyRotationParams, type VaultSyncOptions, type VaultSyncPhase as EngineSyncPhase, type VaultSyncStoreOutcome, type VaultSyncStoreRequest } from '@aliasvault/client/sync/VaultSyncEngine';
import { getVaultSyncHoldReason } from '@aliasvault/client/sync/VaultSyncHold';
import i18n from '@/i18n/i18n';
@@ -535,6 +535,14 @@ export const vaultStore = {
return vaultSync.lookupAccountFingerprint(groupId, accountFingerprint);
},
+ /**
+ * Move an email alias to another manifest, signed with this account's own key.
+ * @param transfer - the alias, its current and new manifest, and the claim version the mailbox reported
+ */
+ transferEmailClaim(transfer: EmailClaimTransfer): Promise<SharingOperationResult> {
+ return vaultSync.transferEmailClaim(transfer);
+ },
+
/**
* Accept an invitation to a shared manifest, signing its grant as this account's own.
* @param invitationId - the invitation
diff --git a/core/client/src/email/AliasOwner.ts b/core/client/src/email/AliasOwner.ts
index 293a474e4..d22ff9b63 100644
--- a/core/client/src/email/AliasOwner.ts
+++ b/core/client/src/email/AliasOwner.ts
@@ -1,7 +1,8 @@
import { sharingText } from '../sharing/SharingView';
import type { Folder } from '../database/repositories/FolderRepository';
-import type { EmailClaimTransferRequest, Mailbox } from '@aliasvault/models/webapi';
+import type { EmailClaimTransfer } from '../sync/VaultSyncEngine';
+import type { Mailbox } from '@aliasvault/models/webapi';
/**
* What an item shows when its email alias receives its emails somewhere else than the item's own vault or shared folder.
@@ -9,19 +10,12 @@ import type { EmailClaimTransferRequest, Mailbox } from '@aliasvault/models/weba
export type AliasOwnerNotice = {
/** Where the alias receives its emails now. */
notice: string;
- /** Whether the user may move the alias to the item's vault or shared folder. */
- canMove: boolean;
+ /** The move to the item's vault or shared folder, or null when the user may not move the alias. */
+ transfer: EmailClaimTransfer | null;
/** The confirmation shown before moving the alias. */
moveConfirm: string;
};
-/**
- * The API surface needed to move an alias, offered by the WebApiService of every host.
- */
-type PostApi = {
- post<TRequest, TResponse>(endpoint: string, data: TRequest, parseJson?: boolean): Promise<TResponse>;
-};
-
/**
* The name of the shared folder a shared manifest is shown as (its root folder carries the manifest id as its id).
* @param folders - all rendered folders
@@ -42,13 +36,13 @@ function sharedFolderName(folders: Pick<Folder, 'Id' | 'ManifestId' | 'Name'>[],
*/
export function aliasOwnerNotice(
email: string,
- mailbox: Pick<Mailbox, 'ownerManifestId' | 'canTransfer'>,
+ mailbox: Pick<Mailbox, 'ownerManifestId' | 'canTransfer' | 'claimVersion'>,
itemManifestId: string,
personalManifestId: string | null,
folders: Pick<Folder, 'Id' | 'ManifestId' | 'Name'>[]
): AliasOwnerNotice | null {
- const owner = mailbox.ownerManifestId?.toLowerCase();
- if (!owner || owner === itemManifestId.toLowerCase()) {
+ const owner = mailbox.ownerManifestId;
+ if (!owner || owner.toLowerCase() === itemManifestId.toLowerCase()) {
return null;
}
@@ -59,7 +53,7 @@ export function aliasOwnerNotice(
const isPersonal = (manifestId: string): boolean => manifestId.toLowerCase() === personalManifestId?.toLowerCase();
return {
notice: isPersonal(owner) ? text.inPersonalVault : text.inSharedFolder(sharedFolderName(folders, owner)),
- canMove: mailbox.canTransfer,
+ transfer: mailbox.canTransfer && mailbox.claimVersion !== null ? { address: email, sourceManifestId: owner, manifestId: itemManifestId, claimVersion: mailbox.claimVersion } : null,
moveConfirm: isPersonal(itemManifestId) ? text.moveToPersonalVaultConfirm(email) : text.moveToSharedFolderConfirm(email, sharedFolderName(folders, itemManifestId)),
};
}
@@ -75,12 +69,3 @@ export function aliasOwnerErrorText(code: string | null | undefined): string | n
}
}
-/**
- * Make the item's manifest the owner of the alias, so new mail for it is delivered there.
- * @param webApi - the host's API client
- * @param address - the alias address
- * @param itemManifestId - the manifest of the item showing the alias
- */
-export async function moveAliasHere(webApi: PostApi, address: string, itemManifestId: string): Promise<void> {
- await webApi.post<EmailClaimTransferRequest, Response>('Vault/email-claims/transfer', { address, targetManifestId: itemManifestId }, false);
-}
diff --git a/core/client/src/sync/VaultSync.ts b/core/client/src/sync/VaultSync.ts
index 3f11fd875..0511e0fde 100644
--- a/core/client/src/sync/VaultSync.ts
+++ b/core/client/src/sync/VaultSync.ts
@@ -20,7 +20,7 @@ import { devError, devLog, devWarn } from '../platform/Logger';
import { VaultMigrationKind } from './VaultManifestMigration';
import { buildVaultSyncRequest, runVaultSyncEngine } from './VaultSyncEngine';
-import type { IVaultSyncEngineHost, LogoutReason, VaultSyncEmailDomains, VaultSyncEngineRequest, VaultSyncEngineResult, VaultSyncEngineResultBase, VaultSyncKeyRotationParams, VaultSyncKeyRotationRefusal, VaultSyncKeyRotationResult, VaultSyncMigrateManifestResult, VaultSyncMigrationStatusResult, VaultSyncOperation, VaultSyncOptions, VaultSyncSharingOperation, VaultSyncSharingParams, VaultSyncSharingResult } from './VaultSyncEngine';
+import type { EmailClaimTransfer, IVaultSyncEngineHost, LogoutReason, VaultSyncEmailDomains, VaultSyncEngineRequest, VaultSyncEngineResult, VaultSyncEngineResultBase, VaultSyncKeyRotationParams, VaultSyncKeyRotationRefusal, VaultSyncKeyRotationResult, VaultSyncMigrateManifestResult, VaultSyncMigrationStatusResult, VaultSyncOperation, VaultSyncOptions, VaultSyncSharingOperation, VaultSyncSharingParams, VaultSyncSharingResult } from './VaultSyncEngine';
import type { SqliteClient } from '../database/SqliteClient';
import type { TranslationKey } from '@aliasvault/i18n';
@@ -246,6 +246,14 @@ export class VaultSync {
return this.runSharingOperation('acceptSharedManifestInvitation', { invitationId, accountFingerprint });
}
+ /**
+ * Move an email alias to another manifest, signed with this account's own key so the server accepts it. Never throws.
+ * @param transfer - the alias, its current and new manifest, and the claim version the mailbox reported
+ */
+ public async transferEmailClaim(transfer: EmailClaimTransfer): Promise<SharingOperationResult> {
+ return this.runSharingOperation('transferEmailClaim', transfer);
+ }
+
/**
* Rotate the account's keys: the engine re-encrypts the personal vault and rewraps every grant under new keys, which
* the server applies in one transaction. On success the vault and the cached chain are stored under the new keys. Never throws.
diff --git a/core/client/src/sync/VaultSyncEngine.ts b/core/client/src/sync/VaultSyncEngine.ts
index 20bfa5ebe..b145e4de4 100644
--- a/core/client/src/sync/VaultSyncEngine.ts
+++ b/core/client/src/sync/VaultSyncEngine.ts
@@ -21,7 +21,7 @@ import type { ISqliteDatabase, SqliteValue } from '../platform/SqliteEngine';
/** The operations the engine runs. */
/** The sharing operations, which take `VaultSyncSharingParams`. */
-export type VaultSyncSharingOperation = 'createSharedManifest' | 'inviteToSharedManifest' | 'updateSharedManifest' | 'lookupAccountFingerprint' | 'acceptSharedManifestInvitation';
+export type VaultSyncSharingOperation = 'createSharedManifest' | 'inviteToSharedManifest' | 'updateSharedManifest' | 'lookupAccountFingerprint' | 'acceptSharedManifestInvitation' | 'transferEmailClaim';
export type VaultSyncOperation = 'fullSync' | 'migrationStatus' | 'migrateManifest' | 'statusCheck' | 'resolveVaultKey' | VaultSyncSharingOperation | 'rotateAccountKeys';
@@ -49,8 +49,14 @@ export type VaultSyncSharingParams = {
name?: string;
invitationId?: string;
accountFingerprint?: string;
+ address?: string;
+ sourceManifestId?: string;
+ claimVersion?: number;
};
+/** Moving an email alias from `sourceManifestId` to `manifestId`, signed over the claim version the server reported. */
+export type EmailClaimTransfer = Required<Pick<VaultSyncSharingParams, 'address' | 'sourceManifestId' | 'manifestId' | 'claimVersion'>>;
+
/** What the host hands the engine at session start (the Rust `SyncRequest`). */
export type VaultSyncEngineRequest = {
operation: VaultSyncOperation;
diff --git a/core/models/src/webapi/Mailbox.ts b/core/models/src/webapi/Mailbox.ts
index a9c488ad6..92ed13f94 100644
--- a/core/models/src/webapi/Mailbox.ts
+++ b/core/models/src/webapi/Mailbox.ts
@@ -14,12 +14,7 @@ export type Mailbox = {
/** Whether the caller may move the alias to another manifest it can access. */
canTransfer: boolean;
-}
-/**
- * Request to move an email alias to another manifest.
- */
-export type EmailClaimTransferRequest = {
- address: string;
- targetManifestId: string;
+ /** The version of the alias claim, which a move to another manifest is signed over. */
+ claimVersion: number | null;
}
diff --git a/core/rust/src/crypto/signing.rs b/core/rust/src/crypto/signing.rs
index ea14b047b..1d702e08c 100644
--- a/core/rust/src/crypto/signing.rs
+++ b/core/rust/src/crypto/signing.rs
@@ -26,6 +26,9 @@ pub const DELIVERY_KEY_LABEL: &str = "aliasvault/v1/sig/delivery-key";
/// The label of the vault name an invitation carries, signed by the inviter.
pub const INVITATION_NAME_LABEL: &str = "aliasvault/v1/sig/invitation-name";
+/// The label of moving an email alias to another manifest, signed by the user who moves it.
+pub const EMAIL_CLAIM_TRANSFER_LABEL: &str = "aliasvault/v1/sig/email-claim-transfer";
+
/// The label of a new signing public key, signed by the signing key it replaces.
pub const SIGNING_KEY_ROTATION_LABEL: &str = "aliasvault/v1/sig/signing-key-rotation";
@@ -97,6 +100,13 @@ pub fn delivery_key_message(manifest_id: &str, public_key: &str, current_revisio
signed_message(DELIVERY_KEY_LABEL, &[normalize(manifest_id).as_bytes(), public_key.as_bytes(), current_revision.to_string().as_bytes()])
}
+/// The signed message of moving `address` from `source_manifest_id` to `target_manifest_id`, bound to the claim version
+/// the server reported so it cannot be replayed after the claim changed.
+pub fn email_claim_transfer_message(address: &str, source_manifest_id: &str, target_manifest_id: &str, claim_version: i64) -> Vec<u8> {
+ let claim_version = claim_version.to_string();
+ signed_message(EMAIL_CLAIM_TRANSFER_LABEL, &[address.as_bytes(), normalize(source_manifest_id).as_bytes(), normalize(target_manifest_id).as_bytes(), claim_version.as_bytes()])
+}
+
/// The signed message of a signing key rotation: the account's new signing public key, vouched for by the previous one.
pub fn signing_key_rotation_message(user_id: &str, new_signing_public_key: &str) -> Vec<u8> {
signed_message(SIGNING_KEY_ROTATION_LABEL, &[user_id.as_bytes(), new_signing_public_key.as_bytes()])
@@ -200,6 +210,15 @@ mod tests {
assert_eq!(crate::common::encoding::hex_encode_lower(&key_certification_message("user-1", "user-2", PUBLIC_KEY_VECTOR)), KEY_CERTIFICATION_MESSAGE_VECTOR);
}
+ /// Known-answer vector for the email claim transfer message, which `Signing.cs` builds too. Never regenerate it.
+ #[test]
+ fn email_claim_transfer_message_known_answer() {
+ let message = email_claim_transfer_message("[email protected]", "0A1B2C3D-0000-0000-0000-000000000001", "0A1B2C3D-0000-0000-0000-000000000002", 1767225600000);
+ assert_eq!(crate::common::encoding::hex_encode_lower(&message), EMAIL_CLAIM_TRANSFER_MESSAGE_VECTOR);
+ }
+
+ const EMAIL_CLAIM_TRANSFER_MESSAGE_VECTOR: &str = "00000026616c6961737661756c742f76312f7369672f656d61696c2d636c61696d2d7472616e7366657200000011616c696173406578616d706c652e636f6d0000002430613162326333642d303030302d303030302d303030302d3030303030303030303030310000002430613162326333642d303030302d303030302d303030302d3030303030303030303030320000000d31373637323235363030303030";
+
const KEY_CERTIFICATION_MESSAGE_VECTOR: &str = "00000023616c6961737661756c742f76312f7369672f6b65792d63657274696669636174696f6e00000006757365722d3100000006757365722d320000002c41364548762f504f454c3464634e3059353076416d57666b316a436270513166486479475a424a564d62673d";
#[test]
diff --git a/core/rust/src/vault_sync/engine.rs b/core/rust/src/vault_sync/engine.rs
index a0fc9343f..54afbaf1f 100644
--- a/core/rust/src/vault_sync/engine.rs
+++ b/core/rust/src/vault_sync/engine.rs
@@ -38,6 +38,7 @@ pub(crate) async fn run(host: Host, request: SyncRequest) -> Value {
SyncOperation::LookupAccountFingerprint => serde_json::to_value(sharing::lookup_account_fingerprint_operation(&mut ctx).await),
SyncOperation::AcceptSharedManifestInvitation => serde_json::to_value(sharing::accept_shared_manifest_invitation_operation(&mut ctx).await),
SyncOperation::RotateAccountKeys => serde_json::to_value(rotation::rotate_account_keys_operation(&mut ctx).await),
+ SyncOperation::TransferEmailClaim => serde_json::to_value(sharing::transfer_email_claim_operation(&mut ctx).await),
};
finish(&ctx, result.unwrap_or(Value::Null))
}
diff --git a/core/rust/src/vault_sync/sharing.rs b/core/rust/src/vault_sync/sharing.rs
index aa64eb09e..2c8bef59c 100644
--- a/core/rust/src/vault_sync/sharing.rs
+++ b/core/rust/src/vault_sync/sharing.rs
@@ -1,5 +1,5 @@
//! The sharing operations that take vault keys or sign something: creating a group's shared manifest, updating one,
-//! inviting to a group or a shared manifest, and accepting those invitations.
+//! inviting to a group or a shared manifest, accepting those invitations, and moving an email alias to another manifest.
//!
//! Trust between two accounts rests on key certifications: once a user has checked another account's signing key (outside
//! AliasVault) against that account's account fingerprint (the key's fingerprint), a client signs a
@@ -123,6 +123,16 @@ struct CertifyKeyRequest<'a> {
signature: &'a str,
}
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+struct EmailClaimTransferRequest<'a> {
+ address: &'a str,
+ source_manifest_id: &'a str,
+ target_manifest_id: &'a str,
+ claim_version: i64,
+ signature: &'a str,
+}
+
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
struct AcceptInvitationRequest<'a> {
@@ -269,6 +279,12 @@ pub(crate) async fn accept_shared_manifest_invitation_operation(ctx: &mut Ctx) -
finish(ctx, "accept shared manifest invitation", outcome).await
}
+/// Move an email alias to another manifest this account can open.
+pub(crate) async fn transfer_email_claim_operation(ctx: &mut Ctx) -> SharingOperationResult {
+ let outcome = transfer_email_claim(ctx).await;
+ finish(ctx, "move email alias", outcome).await
+}
+
/// Turn an operation's outcome into the result the host acts on.
async fn finish(ctx: &Ctx, what: &str, outcome: Outcome) -> SharingOperationResult {
match outcome {
@@ -612,6 +628,23 @@ async fn lookup_account_fingerprint(ctx: &mut Ctx) -> Outcome {
Ok(Ok(Done { username: Some(account.username), already_member, ..Default::default() }))
}
+/// Move an email alias to another manifest, signed with this account's own key so a stolen session token alone cannot redirect mail.
+async fn transfer_email_claim(ctx: &mut Ctx) -> Outcome {
+ let target = params(ctx)?;
+ let address = target.address.as_deref().map(|address| address.trim().to_lowercase()).filter(|address| !address.is_empty()).ok_or_else(|| SyncError::Other("The alias transfer names no address".to_string()))?;
+ let source_manifest_id = target.source_manifest_id.clone().ok_or_else(|| SyncError::Other("The alias transfer names no source manifest".to_string()))?;
+ let target_manifest_id = target.manifest_id.clone().ok_or_else(|| SyncError::Other("The alias transfer names no target manifest".to_string()))?;
+ let claim_version = target.claim_version.ok_or_else(|| SyncError::Other("The alias transfer carries no claim version".to_string()))?;
+ let Some(signing_key) = keys::signing_private_key(ctx).await? else { return Ok(Err(Refusal::VaultUpgradeRequired)) };
+
+ let message = crypto::signing::email_claim_transfer_message(&address, &source_manifest_id, &target_manifest_id, claim_version);
+ let signature = crypto::signing::sign(signing_key.expose_secret(), &message)?;
+ let request = EmailClaimTransferRequest { address: &address, source_manifest_id: &source_manifest_id, target_manifest_id: &target_manifest_id, claim_version, signature: &signature };
+ http::post_no_content(&ctx.host, "Vault/email-claims/transfer", &request).await?;
+ ctx.log(format!("[Sharing] Moved an email alias from manifest {} to manifest {}.", source_manifest_id, target_manifest_id)).await;
+ Ok(Ok(Done { manifest_id: Some(target_manifest_id), ..Default::default() }))
+}
+
/// Accept an invitation to a shared manifest: check the certified inviter signed it and the key inside opens for this
/// account, then sign the grant as this account's own.
async fn accept_shared_manifest_invitation(ctx: &mut Ctx) -> Outcome {
diff --git a/core/rust/src/vault_sync/types.rs b/core/rust/src/vault_sync/types.rs
index e8218eab8..fa45785c4 100644
--- a/core/rust/src/vault_sync/types.rs
+++ b/core/rust/src/vault_sync/types.rs
@@ -38,6 +38,8 @@ pub enum SyncOperation {
AcceptSharedManifestInvitation,
/// Rotate the account's keys and re-encrypt the personal vault under them; see `KeyRotationParams`.
RotateAccountKeys,
+ /// Move an email alias to another manifest (`SharingParams.manifest_id`), signed with this account's own key.
+ TransferEmailClaim,
}
/// What a key rotation needs from the host: the proof of the current password and the new unlock method, both
@@ -77,6 +79,15 @@ pub struct SharingParams {
/// The other party's account fingerprint as the user typed it, for the operations that certify a key.
#[serde(default)]
pub account_fingerprint: Option<String>,
+ /// The email alias an alias transfer moves.
+ #[serde(default)]
+ pub address: Option<String>,
+ /// The manifest that owns the alias before an alias transfer.
+ #[serde(default)]
+ pub source_manifest_id: Option<String>,
+ /// The claim version the server reported for the alias, which an alias transfer signs.
+ #[serde(default)]
+ pub claim_version: Option<i64>,
}
/// Sync request.
diff --git a/docs/docs/security-whitepaper.mdx b/docs/docs/security-whitepaper.mdx
index 732834803..53d9300f0 100644
--- a/docs/docs/security-whitepaper.mdx
+++ b/docs/docs/security-whitepaper.mdx
@@ -127,7 +127,7 @@ AliasVault uses only established primitives standardized by NIST and the IETF; h
| [SRP-6a](https://en.wikipedia.org/wiki/Secure_Remote_Password_protocol) | Password authentication without sending the password | [5](#5-authentication-process) |
| [AES-256-GCM](https://en.wikipedia.org/wiki/Galois/Counter_Mode) | Vault contents, blobs, emails, exports and every key in the hierarchy | [4.1](#41-key-hierarchy), [6](#6-vault-operations), [7](#7-email), [9](#9-login-with-mobile), [10](#10-vault-sharing), [11](#11-protecting-keys-on-the-device), [12](#12-vault-exports) |
| [RSA-OAEP](https://en.wikipedia.org/wiki/Optimal_asymmetric_encryption_padding) | Email encryption, Login with Mobile, vault sharing | [7](#7-email), [9](#9-login-with-mobile), [10](#10-vault-sharing) |
-| [Ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) | Signing public keys, grants, delivery keys and invitations | [4.1](#41-key-hierarchy), [7](#7-email), [10](#10-vault-sharing) |
+| [Ed25519](https://en.wikipedia.org/wiki/EdDSA#Ed25519) | Signing what an account publishes or changes | [4.1](#41-key-hierarchy), [7](#7-email), [10](#10-vault-sharing) |
| [HMAC-SHA256](https://en.wikipedia.org/wiki/HMAC) | Blob addresses, passkey PRF, session token (JWT) signing | [5](#5-authentication-process), [6](#6-vault-operations), [8](#8-passkey-authentication) |
| [SHA-256](https://en.wikipedia.org/wiki/SHA-2) | Integrity checks and key fingerprints | [9](#9-login-with-mobile), [Vault Format and Sync](./security-architecture/vault-format.mdx) |
| [TOTP](https://en.wikipedia.org/wiki/Time-based_one-time_password) | Two-factor authentication | [5](#5-authentication-process) |
@@ -163,7 +163,7 @@ Every unlock method (e.g. master password) opens the same Account Key, which unl
| **AK** (Account Key) | Random 256-bit key, created at registration | The personal VEK and the private keys of both account keypairs | Encrypted with the KEK, one copy per account unlock method |
| **VEK** (Vault Encryption Key) | Random 256-bit key, one per vault: the personal vault and any shared vaults have separate keys | The vault contents and its blob keys | Encrypted with the owner's AK (personal vault) or with each member's account public key (shared vault) |
| **Account encryption keypair** | RSA-2048 keypair, one per user | Private key opens the VEKs of shared vaults this user is a member of | Public key in plaintext (signed with the user's account signing key), private key encrypted with the AK |
-| **Account signing keypair** | Ed25519 keypair, one per user | Signs what the user publishes: their RSA public key, grants, delivery keys and the vault name in an invitation | Public key in plaintext, private key encrypted with the AK |
+| **Account signing keypair** | Ed25519 keypair, one per user | Signs what the user publishes or changes on the server, such as their RSA public key and grants | Public key in plaintext, private key encrypted with the AK |
| **Vault Delivery Keypair** | RSA-2048 keypair, one per vault | Private key opens emails for aliases in that vault | Public key in plaintext, private key stored inside the encrypted vault |
| **Blob key** | Random 256-bit key, one per blob (content stored separately from the rest of the vault, such as the bytes of an attachment or logo) | That blob's bytes | Encrypted with the VEK of the vault the blob belongs to |
@@ -261,6 +261,7 @@ AliasVault encrypts each incoming email in memory as soon as it arrives, with th
- The private key is stored inside that encrypted vault
- The public key is sent to the server together with the vault, signed with the publishing user's account signing key; the server only accepts a key signed by a member allowed to publish it
2. Each alias is registered on the server as an *email claim*, which links the alias to the vault it belongs to
+ - Moving an alias to another vault is signed with the user's account signing key, over the alias, both vaults and the current version of the claim; the server only accepts a move signed by the caller, so a stolen session token alone cannot send an alias's future email to another vault
3. When a member loses access to a shared vault, the Vault Delivery Keypair is replaced, so future emails are encrypted to a new key. Old keypairs are kept in the vault, so emails received before the change stay readable
### 7.2. Email reception process
@@ -422,7 +423,7 @@ Access to a shared vault is called a *grant*: a copy of the vault's VEK encrypte
- **Group membership alone gives no access**: a group itself holds no keys. A user only gets access to a shared vault after being invited to it and accepting, which gives them their own grant.
- **Each key has one job**: the account encryption keypair only receives vault keys, and a Vault Delivery Keypair only decrypts email, so a key stored inside a vault never opens anything outside it.
- **Grants are tied to their vault**: a grant is encrypted under a label that names the vault, so it cannot be used for another vault.
-- **Grants and keys are signed**: a grant, a published account public key and a published delivery key each carry an Ed25519 signature by the account that created it, over a message that names its purpose, so a grant cannot be created by someone who merely knows a public key, and a signature made for one purpose does not verify for another. The server checks every signature on upload. A client opens a shared vault only with a grant signed by its own account, and encrypts a vault key only for a public key signed by a signing key its user certified ([10.3](#103-account-fingerprints-and-key-certifications)). A grant the server made up, signed with a key of its own, therefore never opens, and a shared vault the server serves without content past its first revision is refused.
+- **Grants and keys are signed**: a grant, a published account public key and a published delivery key each carry an Ed25519 signature by the account that created it, over a message that names its purpose, so a grant cannot be created by someone who merely knows a public key, and a signature made for one purpose does not verify for another. The server checks every signature on upload. A client opens a shared vault only with a grant signed by its own account, and encrypts a vault key only for a public key signed by a signing key its user certified ([10.3](#103-account-fingerprints-and-key-certifications)). A grant the server made up, signed with a key of its own, therefore never opens.
- **Own keys come from the private key**: a client uses the account public key the server serves as its own only after checking that it is the public half of the private key it holds, and derives its own signing public key from its signing private key. A server that serves another key as the user's own is refused.
- **Enforcement layers**: access to a vault's contents is enforced by cryptography (no grant, no key). Which vaults the server lists for a user, group membership and roles are enforced by the server. A few guards, such as refusing to delete the folder that represents a shared vault, are enforced only in the client.
@@ -483,7 +484,7 @@ AliasVault also offers two unencrypted formats, to export your data and import i
These are the known limitations of the current design relative to the [threat model](#2-threat-model), including trade-offs made on purpose. Each entry states what an attacker must already have for it to apply, what it allows, and what mitigates it today.
1. <Link id="limitation-shared-member-removal" />**Removing a member from a shared vault ends their access, but keeps the vault's key.** The server stops serving the vault to the removed member, their client deletes its copy, and new email is encrypted to a new delivery key. The VEK stays the same, so the other members are not affected. Only if the removed member later obtains the vault's ciphertext outside the API, from a leaked copy of the server database, could they decrypt it with the VEK they had, including email received after their removal. To fully separate a vault from a former member, create a new shared vault, move the items to it, invite the remaining members, delete the old vault, and change the passwords the former member had access to. The new vault has its own VEK and keypair.
-2. <Link id="limitation-rollback" />**Clients do not detect an older vault revision being served as current.** This affects freshness, not confidentiality or authenticity: the server can only serve a revision that members of the vault wrote earlier, and cannot read, change or create one ([2.4](#24-what-the-server-knows-and-can-do)). A client accepts such a revision as current, so changes made after it are lost and older states of items return. This is a deliberate trade-off: a server restored from a backup after a failure serves older revisions in the same way, and a client that refused them would lock its user out of their vault.
+2. <Link id="limitation-rollback" />**Clients do not detect an older vault revision being served as current.** This affects freshness, not confidentiality or authenticity: the server can only serve a revision that members of the vault wrote earlier or an empty vault, and cannot read, change or create vault contents ([2.4](#24-what-the-server-knows-and-can-do)). A client accepts such a revision as current, so changes made after it are lost and older states of items return. This is a deliberate trade-off: a server restored from a backup after a failure serves older revisions in the same way, and a client that refused them would lock its user out of their vault.
3. <Link id="limitation-pin-unlock" />**PIN unlock in the browser extension is an opt-in convenience.** PIN unlock is off by default and the master password is the default unlock method; the PIN setting notes that a PIN can be less secure than the master password. The Account Key is encrypted under a key derived from the PIN with Argon2id, and the 4-attempt limit applies to guesses made through the extension. An attacker who has copied the extension's storage, which requires forensic access or a compromised device ([2.5](#25-out-of-scope)), is not bound by that limit and can try PINs offline at the cost of one Argon2id derivation per guess, which is feasible for a 6-digit PIN; a longer PIN with letters and symbols takes more guesses. On mobile, the PIN-encrypted Account Key is also encrypted with a device-bound key from the iOS Keychain or the Android Keystore, so a copy of the app's storage alone is not enough to start guessing.
4. <Link id="limitation-post-quantum" />**Public-key encryption uses RSA-2048, not yet a post-quantum algorithm.** Grants, email keys and Login with Mobile use RSA-2048-OAEP. An attacker who keeps a copy of that ciphertext (from the server database or captured traffic) could decrypt it once a quantum computer able to break RSA-2048 exists, and with it the shared vault keys, emails and Account Keys it protects. RSA-2048 provides 112-bit security, which NIST SP 800-57 Part 1 approves through 2030; the NIST draft transition plan (IR 8547) sets 2035 for moving public-key encryption to post-quantum algorithms. Vault contents and the keys that protect the personal vault at rest use AES-256-GCM, which is considered safe against quantum computers. Every RSA ciphertext carries an algorithm identifier, so a post-quantum scheme can be added next to RSA without breaking existing data; it will be added once well-reviewed implementations exist on every platform AliasVault supports.
5. <Link id="limitation-argon2-parameters" />**A new device accepts any Argon2id settings at or above the OWASP recommended minimum.** Accounts use 64 MiB and 5 iterations, but a device that has never logged in before does not know that, so it accepts any settings down to the OWASP minimum of 19 MiB and 2 iterations ([section 4](#4-key-derivation-and-key-hierarchy)). A malicious server could send that minimum to a new device and obtain one login proof to guess the master password against at the lower cost. That minimum is still the current OWASP recommendation, a device that logged in before refuses weaker settings than it used, and a leaked database only allows guessing at the account's own settings. The minimum is set to the OWASP minimum because that was the default for accounts until version 0.31.0. Once all accounts have migrated to the current defaults, the minimum will be raised to match them.