From 1d96c17b2fb214b406f5101e8ef19816129ee086 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 22 Nov 2026 09:11:10 +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 f86529b7..d2d76a4c 100644 --- a/mmgen/tx/completed.py +++ b/mmgen/tx/completed.py @@ -97,10 +97,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'))