cryptonote_protocol: tighten pruned transaction blob validation

(cherry picked from commit 71e3be0e48d0939dfd2500f703b69234967d254a)
This commit is contained in:
selsta
2026-10-04 18:50:24 -04:00
committed by such-gitea
parent 6d9aca92f1
commit cb893bf197
3 changed files with 4 additions and 3 deletions
@@ -253,11 +253,12 @@ namespace cryptonote
return true;
}
//---------------------------------------------------------------
bool parse_and_validate_tx_base_from_blob(const blobdata_ref& tx_blob, transaction& tx)
bool parse_and_validate_tx_base_from_blob(const blobdata_ref& tx_blob, transaction& tx, const bool require_eof)
{
binary_archive<false> ba{epee::strspan<std::uint8_t>(tx_blob)};
bool r = tx.serialize_base(ba);
CHECK_AND_ASSERT_MES(r, false, "Failed to parse transaction from blob");
CHECK_AND_ASSERT_MES(::serialization::check_stream_state(ba, !require_eof), false, "Unexpected trailing data after transaction base");
CHECK_AND_ASSERT_MES(expand_transaction_1(tx, true), false, "Failed to expand transaction data");
tx.invalidate_hashes();
return true;
@@ -56,7 +56,7 @@ namespace cryptonote
bool parse_and_validate_tx_from_blob(const blobdata_ref& tx_blob, transaction& tx, crypto::hash& tx_hash, crypto::hash& tx_prefix_hash);
bool parse_and_validate_tx_from_blob(const blobdata_ref& tx_blob, transaction& tx, crypto::hash& tx_hash);
bool parse_and_validate_tx_from_blob(const blobdata_ref& tx_blob, transaction& tx);
bool parse_and_validate_tx_base_from_blob(const blobdata_ref& tx_blob, transaction& tx);
bool parse_and_validate_tx_base_from_blob(const blobdata_ref& tx_blob, transaction& tx, const bool require_eof = false);
bool is_v1_tx(const blobdata_ref& tx_blob);
bool is_v1_tx(const blobdata& tx_blob);
@@ -115,7 +115,7 @@ namespace cryptonote
bool parse_success = false;
if (is_pruned)
{
if ((parse_success = cryptonote::parse_and_validate_tx_base_from_blob(tx_entry.blob, tx)))
if ((parse_success = cryptonote::parse_and_validate_tx_base_from_blob(tx_entry.blob, tx, /*require_eof=*/true)))
parse_success = cryptonote::get_pruned_transaction_hash(tx, tx_entry.prunable_hash, tx_hash);
}
else