From ab545e189f9a0c9451061e8ceb3162b348552017 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 22 Nov 2026 09:28:49 +0000 Subject: [PATCH] tx.file: require `have_wif` field to be absent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes a vulnerability whereby an attacker with access to the online machine could bypass the address-belongs-to-wallet test performed by the offline signer by crafting a transaction file with the “have_wif” field set for a transaction output. --- mmgen/data/version | 2 +- mmgen/tx/file.py | 5 +++++ mmgen/tx/keys.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mmgen/data/version b/mmgen/data/version index 5905cac3..88d527ef 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -17.1.0dev2 +17.1.0dev3 diff --git a/mmgen/tx/file.py b/mmgen/tx/file.py index ceb86868..4b0ed3e9 100644 --- a/mmgen/tx/file.py +++ b/mmgen/tx/file.py @@ -47,6 +47,11 @@ def eval_io_data(tx, data, *, desc): if not (desc == 'outputs' and tx.proto.base_coin == 'ETH'): # ETH txs can have no outputs assert len(data), f'no {desc}!' for d in data: + if 'have_wif' in d: + die( + 'TxKeysError', + f'transaction file {desc} contains extraneous ‘have_wif’ field. ' + 'Your online installation may be compromised!') d['amt'] = tx.proto.coin_amt(d['amt']) io, io_list = { 'inputs': (tx.Input, tx.InputList), diff --git a/mmgen/tx/keys.py b/mmgen/tx/keys.py index 820ff71b..26e7508b 100644 --- a/mmgen/tx/keys.py +++ b/mmgen/tx/keys.py @@ -214,7 +214,7 @@ class TxKeys: ret = self.get_keys_for_non_mmgen_inputs() memo_output = self.tx.check_swap_memo() # do this for non-swap transactions too! okeys, mkeys = ([], []) - num_okeys = len([e for e in self.tx.outputs if e.mmid and not e.have_wif]) + num_okeys = len([e for e in self.tx.outputs if e.mmid]) num_mkeys = 1 if memo_output and memo_output.mmid else None if self.keyaddrlist: