From bd2fae9ca5c9e1ebb25f5e85c83d4c844c663ef4 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 22 Apr 2026 18:30:24 +0000 Subject: [PATCH] fix(marmot): scope Marmot storage per-account to prevent chat leakage The three Marmot stores (MLS group state, messages, KeyPackage bundles) were all initialized with the global app filesDir, so chats and MLS state from one account were visible to any other logged-in account. Pass each store a per-account subdirectory (accounts/) derived from the signer pubkey, so paths become: files/accounts//mls_groups//{state,retained,messages} files/accounts//marmot_keypackages/state Existing in-memory state was already scoped per-Account; this closes the last remaining cross-account leak on disk. --- .../amethyst/model/accountsCache/AccountCacheState.kt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt index baf2ee137..cbf023d8c 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/model/accountsCache/AccountCacheState.kt @@ -100,13 +100,14 @@ class AccountCacheState( val signerWithClientTag = NostrSignerWithClientTag(signer, CLIENT_TAG_NAME) + val accountDir = File(rootFilesDir(), "accounts/${signer.pubKey}").apply { mkdirs() } + val mlsStore = try { - val dir = rootFilesDir() Log.d("AccountCacheState") { - "Initializing AndroidMlsGroupStateStore for ${signer.pubKey.take(8)}… at ${dir.absolutePath}" + "Initializing AndroidMlsGroupStateStore for ${signer.pubKey.take(8)}… at ${accountDir.absolutePath}" } - AndroidMlsGroupStateStore(dir) + AndroidMlsGroupStateStore(accountDir) } catch (e: Exception) { Log.e( "AccountCacheState", @@ -121,7 +122,7 @@ class AccountCacheState( val marmotMessageStore = try { - AndroidMarmotMessageStore(rootFilesDir()) + AndroidMarmotMessageStore(accountDir) } catch (e: Exception) { Log.e( "AccountCacheState", @@ -133,7 +134,7 @@ class AccountCacheState( val marmotKeyPackageStore = try { - AndroidKeyPackageBundleStore(rootFilesDir()) + AndroidKeyPackageBundleStore(accountDir) } catch (e: Exception) { Log.e( "AccountCacheState",