fix(legacy): forbid removed Unchained path
What changed, and why it matters
This commit fixes a bug in the Trezor Model One (legacy) firmware where an old, removed multisig key path pattern was still being accepted as valid. Because the path was treated as known, the device would show or sign with it without warning, even when the path belonged to one cryptocurrency (e.g., Bitcoin) but was used on another (e.g., Litecoin or Testnet). The fix makes the firmware reject this leftover pattern as an unknown path, matching the behavior of newer Trezor Core firmware.
Apply the patch to legacy firmware builds and run the added device tests (test_getaddress_show.py and test_signtx_invalid_path.py) to confirm that the removed Unchained path is rejected and that the PromptTemporarily warning flow is shown. Consider auditing other long-lived path-validation branches for similar half-removed patterns.
Security signals we found
Cross-coin key-path confusion: Bitcoin-derived multisig path accepted on Litecoin/Testnet
Missing unknown-path warning under PromptTemporarily safety checks
Inconsistent path validation between legacy and Core firmware
Deprecated/removed BIP-45-style Unchained Capital pattern still partially trusted
Address display and transaction signing possible for non-standard m/45' paths
Evidence from the diff
In legacy/firmware/crypto.c, coin_path_check() had a five-element m/45’ branch left over from the deprecated Unchained Capital pattern m/45’/coin_type’/account’/[0-1000000]/address_index. The branch validated account/change/address bounds but did not reject a hardened address_n[1] (coin_type). As a result, paths such as m/45’/0’/0’/0/0 were accepted as valid for any coin. With Strict safety checks, GetAddress displayed the multisig address and SignTx signed a Bitcoin-path multisig input on Litecoin; with PromptTemporarily, no unknown-path warning was shown. The patch adds an else { return false; } so any non-conforming five-element m/45’ path is rejected, aligning with the other branches and with Trezor Core. New tests verify rejection for Bitcoin, Bitcoin path on Testnet, an unenumerable account, and Litecoin signing, plus the expected warning flow when safety checks are set to prompt.
Changed components
legacy/firmware/crypto.c:coin_path_check()legacy firmware path validation for InputScriptType.SPENDMULTISIGlegacy GetAddress and SignTx operations with multisig pathslegacy safety-check handling (Strict / PromptTemporarily)Inspect captured patch +135 / −1
### legacy/firmware/.changelog.d/+unchained-path.security
@@ -0,0 +1 @@
+Treat the removed Unchained Capital multisig path as an unknown path.
### legacy/firmware/crypto.c
@@ -592,6 +592,8 @@ bool coin_path_check(const CoinInfo *coin, InputScriptType script_type,
valid = valid && (address_n[2] <= PATH_MAX_ACCOUNT);
valid = valid && (address_n[3] <= PATH_MAX_CHANGE);
valid = valid && (address_n[4] <= PATH_MAX_ADDRESS_INDEX);
+ } else {
+ return false;
}
} else {
return false;
### tests/device_tests/bitcoin/test_getaddress_show.py
@@ -136,6 +136,40 @@ def test_show_unrecognized_path(session: Session):
)
+# Removed Unchained pattern m/45'/coin_type'/account'/[0-1000000]/address_index
+@pytest.mark.multisig
+@pytest.mark.parametrize(
+ "coin_name, account, address_n",
+ (
+ pytest.param("Bitcoin", 0, [0, 0], id="bitcoin"),
+ pytest.param("Testnet", 0, [0, 0], id="bitcoin_path_on_testnet"),
+ pytest.param("Bitcoin", 7777, [1, 5_000_000], id="unenumerable"),
+ ),
+)
+def test_show_multisig_unrecognized_path(
+ session: Session, coin_name: str, account: int, address_n: list[int]
+):
+ nodes = [
+ btc.get_public_node(
+ session, tools.parse_path(f"m/45h/0h/{account + i}h"), coin_name="Bitcoin"
+ ).node
+ for i in range(3)
+ ]
+ multisig = messages.MultisigRedeemScriptType(
+ nodes=nodes, signatures=[b"", b"", b""], m=2, address_n=address_n
+ )
+
+ with pytest.raises(TrezorFailure, match="Forbidden key path"):
+ btc.get_address(
+ session,
+ coin_name,
+ tools.parse_path(f"m/45h/0h/{account}h") + address_n,
+ show_display=True,
+ multisig=multisig,
+ script_type=messages.InputScriptType.SPENDMULTISIG,
+ )
+
+
@pytest.mark.multisig
def test_show_multisig_3(session: Session):
nodes = [
### tests/device_tests/bitcoin/test_signtx_invalid_path.py
@@ -23,7 +23,13 @@
from ...common import is_core
from ...input_flows import InputFlowConfirmAllWarnings
-from .signtx import forge_prevtx, request_input
+from .signtx import (
+ forge_prevtx,
+ request_finished,
+ request_input,
+ request_meta,
+ request_output,
+)
B = messages.ButtonRequestType
@@ -32,6 +38,11 @@
PREV_HASH, PREV_TX = forge_prevtx([(INPUT_ADDRESS, 390_000)])
PREV_TXES = {PREV_HASH: PREV_TX}
+# 2-of-3 multisig address of m/45h/0h/{0,1,2}h/0/0 at seed "all all all..."
+MULTISIG_INPUT_ADDRESS = "39sEofM1QCi3cDa8mjwrujEctBoNvMbytL"
+MULTISIG_PREV_HASH, MULTISIG_PREV_TX = forge_prevtx([(MULTISIG_INPUT_ADDRESS, 390_000)])
+MULTISIG_PREV_TXES = {MULTISIG_PREV_HASH: MULTISIG_PREV_TX}
+
# Litecoin does not have strong replay protection using SIGHASH_FORKID,
# spending from Bitcoin path should fail.
@@ -88,6 +99,92 @@ def test_invalid_path_prompt(session: Session):
btc.sign_tx(session, "Litecoin", [inp1], [out1], prev_txes=PREV_TXES)
+def _unchained_removed_multisig_input(session: Session) -> messages.TxInputType:
+ # Removed Unchained pattern, now an unknown path:
+ # m/45'/coin_type'/account'/[0-1000000]/address_index
+ nodes = [
+ btc.get_public_node(
+ session, parse_path(f"m/45h/0h/{i}h"), coin_name="Bitcoin"
+ ).node
+ for i in range(3)
+ ]
+ multisig = messages.MultisigRedeemScriptType(
+ nodes=nodes, address_n=[0, 0], signatures=[b"", b"", b""], m=2
+ )
+ return messages.TxInputType(
+ address_n=parse_path("m/45h/0h/0h/0/0"),
+ amount=390_000,
+ prev_hash=MULTISIG_PREV_HASH,
+ prev_index=0,
+ script_type=messages.InputScriptType.SPENDMULTISIG,
+ multisig=multisig,
+ )
+
+
+# Spending a multisig input from an unknown Bitcoin path on Litecoin should fail.
+@pytest.mark.altcoin
+@pytest.mark.multisig
+def test_invalid_path_multisig_fail(session: Session):
+ inp1 = _unchained_removed_multisig_input(session)
+
+ # address is converted from 1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1 by changing the version
+ out1 = messages.TxOutputType(
+ address="LfWz9wLHmqU9HoDkMg9NqbRosrHvEixeVZ",
+ amount=390_000 - 10_000,
+ script_type=messages.OutputScriptType.PAYTOADDRESS,
+ )
+
+ with pytest.raises(TrezorFailure) as exc:
+ btc.sign_tx(session, "Litecoin", [inp1], [out1], prev_txes=MULTISIG_PREV_TXES)
+
+ assert exc.value.code == messages.FailureType.DataError
+ assert exc.value.message.endswith("Forbidden key path")
+
+
+# With safety checks set to prompt, the same spend should pass only after the
+# unknown path warning.
+@pytest.mark.altcoin
+@pytest.mark.multisig
+def test_invalid_path_multisig_prompt(session: Session):
+ inp1 = _unchained_removed_multisig_input(session)
+
+ # address is converted from 1MJ2tj2ThBE62zXbBYA5ZaN3fdve5CPAz1 by changing the version
+ out1 = messages.TxOutputType(
+ address="LfWz9wLHmqU9HoDkMg9NqbRosrHvEixeVZ",
+ amount=390_000 - 10_000,
+ script_type=messages.OutputScriptType.PAYTOADDRESS,
+ )
+
+ device.apply_settings(
+ session, safety_checks=messages.SafetyCheckLevel.PromptTemporarily
+ )
+
+ with session.test_ctx as client:
+ client.set_expected_responses(
+ [
+ request_input(0),
+ messages.ButtonRequest(code=B.UnknownDerivationPath),
+ request_output(0),
+ messages.ButtonRequest(code=B.ConfirmOutput),
+ (is_core(session), messages.ButtonRequest(code=B.ConfirmOutput)),
+ messages.ButtonRequest(code=B.SignTx),
+ request_input(0),
+ request_meta(MULTISIG_PREV_HASH),
+ request_input(0, MULTISIG_PREV_HASH),
+ request_output(0, MULTISIG_PREV_HASH),
+ request_input(0),
+ request_output(0),
+ request_output(0),
+ request_finished(),
+ ]
+ )
+ if is_core(session):
+ IF = InputFlowConfirmAllWarnings(session)
+ client.set_input_flow(IF.get())
+
+ btc.sign_tx(session, "Litecoin", [inp1], [out1], prev_txes=MULTISIG_PREV_TXES)
+
+
# Bcash does have strong replay protection using SIGHASH_FORKID,
# spending from Bitcoin path should work.
@pytest.mark.altcoinWhy this scored 64/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.