The vulnerability lies in the handleAllowlistCommand function within src/auto-reply/reply/commands-allowlist.ts. This function processes the /allowlist command, which can be used to manage sender authorizations. The vulnerability occurs when this command is used with the --store flag for a specific account. The function correctly identifies the target accountId for reading the current configuration but fails to use this accountId when writing the changes back to the persistent pairing store.
The patch shows that the direct calls to addChannelAllowFromStoreEntry and removeChannelAllowFromStoreEntry were made without the accountId. This caused the allowlist entry to be saved in a legacy, unscoped storage location. According to the vulnerability description, the logic for reading the allowlist for the default account merges entries from this legacy store. Consequently, an authorized user for a non-default account could add a sender to their allowlist, and that sender would also be authorized for the default account, which is an improper authorization expansion across accounts.
The fix introduces a new function, updatePairingStoreAllowlist, which takes the accountId as a parameter and passes it to the store writing functions. The handleAllowlistCommand is updated to use this new function, ensuring that all write operations to the pairing store are correctly scoped to the intended account. The fix also includes logic to clean up legacy unscoped entries upon removal to prevent further cross-account authorization issues.