From 1be9184b566b98546e087f8c0d0b0b2eb0173794 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 22 Nov 2026 09:28:48 +0000 Subject: [PATCH] check_swap_memo(): require `is_swap` to be set if memo present in transaction 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 containing a swap memo but with the “is_swap” field unset or set to false. --- mmgen/tx/completed.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mmgen/tx/completed.py b/mmgen/tx/completed.py index 1f363d2f..1e712e26 100644 --- a/mmgen/tx/completed.py +++ b/mmgen/tx/completed.py @@ -101,10 +101,13 @@ class Completed(Base): tokensym = r.tokensym, need_amt = True) + if not (self.is_swap or self.is_deposit): + raise ValueError( + 'Swap memo present in transaction but ‘is_swap’ field not set. ' + 'Your online installation may be compromised!') + if mmid := getattr(self, 'swap_recv_addr_mmid', None): return self.Output(proto, addr=p.address, mmid=mmid, amt=proto.coin_amt('0')) - elif not self.is_swap: - pass elif self.cfg.allow_non_wallet_swap: ymsg('Warning: allowing swap to non-wallet address (--allow-non-wallet-swap)') return self.Output(proto, addr=p.address, mmid=None, amt=proto.coin_amt('0'))