Merge pull request #742 from Foundation-Devices/sft-8530-distinct-cosigners
What changed, and why it matters
This update to the Passport hardware wallet firmware adds a safety check when importing multi-signature wallet configurations. Previously, the same cosigner public key could be listed more than once under different fingerprints or address formats. Now the device rejects duplicate cosigner keys, preventing a user from being tricked into thinking they have an independent cosigner when they actually do not. This is a security hardening fix for a logic flaw in multisig import validation.
Review whether the same duplicate-cosigner check is also applied during PSBT signing and descriptor-based imports, and consider adding integration tests for those paths. Ensure the assertion is surfaced to the user as a clear error rather than a crash.
Security signals we found
Adds duplicate-key detection during multisig wallet import
Compares raw public-key x-coordinates rather than fingerprints or encoded xpub strings
Prevents a single key from being counted as multiple independent cosigners
Includes a new unit test covering same-key-different-fingerprint and same-key-different-format cases
Evidence from the diff
The patch modifies MultisigWallet.check_xpub() to compare the x-coordinate (public_key()[1:]) of each newly imported cosigner against the x-coordinates of already accepted cosigners, regardless of the fingerprint or SLIP-132 encoding used. If a duplicate public key is detected, an AssertionError is raised with the message ‘Duplicate cosigner key.’ A unit test is added to verify that the same key under a different fingerprint or a different address format is rejected, while a genuinely distinct key is still accepted.
Changed components
ports/stm32/boards/Passport/modules/multisig_wallet.pyports/stm32/boards/Passport/modules/tests/test_unit.pyports/stm32/boards/Passport/modules/tests/unit/multisig_distinct_cosigners.pyInspect captured patch +69 / −0
### ports/stm32/boards/Passport/modules/multisig_wallet.py
@@ -758,6 +758,13 @@ def check_xpub(cls, xfp, xpub, deriv, expect_chain, my_xfp, xpubs):
# print('xpubs={}'.format(xpubs))
# assert node.private_key() == None # 'no privkeys plz'
+
+ # Each cosigner must be a different key, whatever fingerprint it is
+ # listed under. Compare x-coordinates, as Passport Prime does.
+ key = node.public_key()[1:]
+ for _, _, accepted in xpubs:
+ assert import_xpub(accepted)[0].public_key()[1:] != key, 'Duplicate cosigner key.'
+
assert chain.ctype == expect_chain, \
"The imported chain type doesn't match passport's current chain." # 'wrong chain'
### ports/stm32/boards/Passport/modules/tests/test_unit.py
@@ -174,3 +174,7 @@ def test_microsd_message_length(test):
def test_scv_challenge(test):
assert test('scv_challenge.py') == b'OK'
+
+
+def test_multisig_distinct_cosigners(test):
+ assert test('multisig_distinct_cosigners.py') == b'OK'
### ports/stm32/boards/Passport/modules/tests/unit/multisig_distinct_cosigners.py
@@ -0,0 +1,58 @@
+# SPDX-FileCopyrightText: © 2026 Foundation Devices, Inc. <hello@foundation.xyz>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# Every cosigner in an imported multisig wallet is a different key, whatever
+# fingerprint label the config gives it. Both config import and PSBT import
+# add cosigners through check_xpub().
+
+import chains
+import trezorcrypto
+
+from multisig_wallet import MultisigWallet
+from public_constants import AF_P2SH, AF_P2WSH
+
+DERIVATION = "m/48'/0'/0'/2'"
+PATH = [0x80000000 | 48, 0x80000000, 0x80000000, 0x80000000 | 2]
+
+
+def account_node(seed_byte):
+ seed = trezorcrypto.bip39.seed(trezorcrypto.bip39.from_data(bytes([seed_byte]) * 16), '')
+ node = trezorcrypto.bip32.from_seed(seed, 'secp256k1')
+ for element in PATH:
+ node.derive(element)
+ return node
+
+
+def add(xpubs, xfp, xpub):
+ return MultisigWallet.check_xpub(xfp, xpub, DERIVATION, 'BTC', 0, xpubs)
+
+
+def assert_refused(xpubs, xfp, xpub):
+ count = len(xpubs)
+ try:
+ add(xpubs, xfp, xpub)
+ except AssertionError as exc:
+ assert 'Duplicate cosigner key' in str(exc), str(exc)
+ else:
+ raise AssertionError('a repeated cosigner key was accepted')
+ assert len(xpubs) == count
+
+
+btc = chains.get_chain('BTC')
+first, second, third = account_node(1), account_node(2), account_node(3)
+
+xpubs = []
+add(xpubs, 0x11111111, btc.serialize_public(first, AF_P2SH))
+add(xpubs, 0x22222222, btc.serialize_public(second, AF_P2SH))
+assert len(xpubs) == 2
+
+# The same key under another fingerprint label is refused, including when it
+# is encoded differently (SLIP-132), since the keys themselves are compared.
+assert_refused(xpubs, 0x33333333, btc.serialize_public(first, AF_P2SH))
+assert_refused(xpubs, 0x33333333, btc.serialize_public(second, AF_P2WSH))
+
+# A third, distinct key is still accepted.
+add(xpubs, 0x33333333, btc.serialize_public(third, AF_P2SH))
+assert len(xpubs) == 3
+
+return_value.write(b'OK')Why this scored 60/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.