What changed, and why it matters
This change stops a Monero wallet from creating 'InProofs' (receipt proofs) for transactions that the wallet itself sent. InProofs are meant to prove to someone else that you received money. If a wallet could generate an InProof for a transaction it sent, a user might trick someone into believing they had received funds when they had actually sent them to themselves (including change outputs). The patch adds a guard that refuses to create such proofs and updates tests to verify the refusal.
Review the completeness of the guard: ensure the spends_one_of_ours and get_tx_key_cached checks cover all cases where a wallet could generate an InProof for an outgoing transaction, and consider whether check_tx_proof verification should also reject such proofs for defense in depth.
Security signals we found
Prevents generation of misleading InProofs for outgoing/self-sent transactions
Adds explicit runtime guard in wallet proof generation path
Functional tests updated to assert refusal behavior
Potential proof-forgery/misrepresentation scenario mitigated
Evidence from the diff
In wallet2::get_tx_proof, when the requested proof type is an InProof (incoming/receipt proof) and the transaction is not already identified as incoming, the code now checks whether the transaction spends one of the wallet’s own outputs or whether the wallet has a cached tx secret key for it. If either is true, it throws a wallet_internal_error with the message ‘InProofs are not allowed for transactions sent by this wallet.’ The functional test proofs.py replaces previous InProof generation for the sending address with a helper that asserts refusal, and adds a new test covering subaddress and standard-address cases where the wallet sends to itself.
Changed components
src/wallet/wallet2.cpptests/functional_tests/proofs.pyInspect captured patch +47 / −39
### src/wallet/wallet2.cpp
@@ -12895,6 +12895,11 @@ std::string wallet2::get_tx_proof(const crypto::hash &txid, const cryptonote::ac
{
THROW_WALLET_EXCEPTION_IF(!get_tx_key(txid, tx_key, additional_tx_keys), error::wallet_internal_error, "Tx secret key wasn't found in the wallet file.");
}
+ else
+ {
+ THROW_WALLET_EXCEPTION_IF(spends_one_of_ours(tx) || get_tx_key_cached(txid, tx_key, additional_tx_keys), error::wallet_internal_error,
+ "InProofs are not allowed for transactions sent by this wallet.");
+ }
return get_tx_proof(tx, tx_key, additional_tx_keys, address, is_subaddress, message);
}
### tests/functional_tests/proofs.py
@@ -44,6 +44,7 @@ def run_test(self):
self.check_tx_proof(txid, amount)
self.check_spend_proof(txid)
self.check_reserve_proof()
+ self.check_tx_proof_sent_tx()
def reset(self):
print('Resetting blockchain')
@@ -127,42 +128,14 @@ def check_tx_proof(self, txid, amount):
sending_address = '42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
receiving_address = '44Kbx4sJ7JDRDV5aAhLJzQCjDz2ViLRduE3ijDZu3osWKBjMGkV1XPk4pfDUMqt1Aiezvephdqm6YD19GKFD9ZcXVUTp6BW'
- res = self.wallet[0].get_tx_proof(txid, sending_address, 'foo');
- assert res.signature.startswith('InProofV2');
- signature0i = res.signature
+ self.check_inproof_refused(self.wallet[0], txid, sending_address)
res = self.wallet[0].get_tx_proof(txid, receiving_address, 'bar');
assert res.signature.startswith('OutProofV2');
signature0o = res.signature
res = self.wallet[1].get_tx_proof(txid, receiving_address, 'baz');
assert res.signature.startswith('InProofV2');
signature1 = res.signature
- res = self.wallet[0].check_tx_proof(txid, sending_address, 'foo', signature0i);
- assert res.good
- assert res.received > 0 # likely change
- assert not res.in_pool
- assert res.confirmations == 1
-
- ok = False
- try: res = self.wallet[0].check_tx_proof('0' * 64, sending_address, 'foo', signature0i);
- except: ok = True
- assert ok or not res.good
-
- ok = False
- try: res = self.wallet[0].check_tx_proof(txid, receiving_address, 'foo', signature0i);
- except: ok = True
- assert ok or not res.good
-
- ok = False
- try: res = self.wallet[0].check_tx_proof(txid, sending_address, '', signature0i);
- except: ok = True
- assert ok or not res.good
-
- ok = False
- try: res = self.wallet[0].check_tx_proof(txid, sending_address, 'foo', signature1);
- except: ok = True
- assert ok or not res.good
-
res = self.wallet[0].check_tx_proof(txid, receiving_address, 'bar', signature0o);
assert res.good
@@ -185,11 +158,6 @@ def check_tx_proof(self, txid, amount):
except: ok = True
assert ok or not res.good
- ok = False
- try: res = self.wallet[0].check_tx_proof(txid, receiving_address, 'bar', signature0i);
- except: ok = True
- assert ok or not res.good
-
res = self.wallet[1].check_tx_proof(txid, receiving_address, 'baz', signature1);
assert res.good
@@ -219,11 +187,6 @@ def check_tx_proof(self, txid, amount):
# Test bad cross-version verification
- ok = False
- try: res = self.wallet[0].check_tx_proof(txid, sending_address, 'foo', signature0i.replace('ProofV2','ProofV1'));
- except: ok = True
- assert ok or not res.good
-
ok = False
try: res = self.wallet[0].check_tx_proof(txid, receiving_address, 'bar', signature0o.replace('ProofV2','ProofV1'));
except: ok = True
@@ -234,6 +197,46 @@ def check_tx_proof(self, txid, amount):
except: ok = True
assert ok or not res.good
+ def check_tx_proof_sent_tx(self):
+ daemon = Daemon()
+
+ print('Checking tx proof refusal for our own addresses in our own transactions')
+
+ # wallet 0's subaddress (0, 1), and the standard address with wallet 0's main view key and the spend key of (0, 1)
+ addresses = [
+ '84QRUYawRNrU3NN1VpFRndSukeyEb3Xpv8qZjjsoJZnTYpDYceuUTpog13D7qPxpviS7J29bSgSkR11hFFoXWk2yNdsR9WF',
+ '43aH9Aw6pxSU3NN1VpFRndSukeyEb3Xpv8qZjjsoJZnTYoZyi8rAUC9PbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJGNYTi4',
+ ]
+ txids = []
+ for address in addresses:
+ res = self.wallet[0].transfer([{'address': address, 'amount': 1000000000}])
+ txids.append(res.tx_hash)
+ self.check_inproof_refused(self.wallet[0], res.tx_hash, address)
+
+ sending_address ='42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm'
+ txid = daemon.getblockheaderbyheight(1).block_header.miner_tx_hash
+ res = self.wallet[0].get_tx_proof(txid, sending_address, 'foo')
+ assert res.signature.startswith('InProofV2')
+ res = self.wallet[0].check_tx_proof(txid, sending_address, 'foo', res.signature)
+ assert res.good
+ assert res.received > 0
+
+ view_key =self.wallet[0].query_key('view_key').key
+ key_images = self.wallet[0].export_key_images(True)
+ self.wallet[1].close_wallet()
+ self.wallet[1].generate_from_keys(viewkey = view_key, address = sending_address)
+ self.wallet[1].refresh()
+ self.wallet[1].import_key_images(key_images.signed_key_images, offset = key_images.offset)
+ self.check_inproof_refused(self.wallet[1], txids[0], addresses[0])
+
+ def check_inproof_refused(self, wallet, txid, address):
+ ok = False
+ try: wallet.get_tx_proof(txid, address, 'foo')
+ except Exception as e:
+ assert 'InProofs are not allowed for transactions sent by this wallet' in str(e)
+ ok = True
+ assert ok
+
def check_spend_proof(self, txid):
daemon = Daemon()
Why this scored 44/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.