From 9ad085bd8397287e8876673d6b8613add9cf73a1 Mon Sep 17 00:00:00 2001 From: Antoine Poinsot Date: Tue, 5 May 2026 07:52:08 -0400 Subject: [PATCH] validation: correct lifetime of precomputed tx data This makes sure `txsdata` always outlives the Script check queue (since local objects are destructed in reverse order of construction). This is the root cause for a security vulnerability reported by Cory Fields in 2024 that could be exploited by crafting an invalid block to cause nodes to read freed memory. The vulnerability was covertly fixed in commit `492e1f09943fcb6145c21d470299305a19e17d8b`. See security advisory for CVE-2024-52911 for more details. Github-Pull: #35209 Rebased-From: 1ed799fb21db51a12cbd5579420a61b9b5b3ee7d --- src/validation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validation.cpp b/src/validation.cpp index 3d6ebd30e5b..90711c2089a 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -2615,8 +2615,8 @@ bool Chainstate::ConnectBlock(const CBlock& block, BlockValidationState& state, // in multiple threads). Preallocate the vector size so a new allocation // doesn't invalidate pointers into the vector, and keep txsdata in scope // for as long as `control`. - CCheckQueueControl control(fScriptChecks && parallel_script_checks ? &m_chainman.GetCheckQueue() : nullptr); std::vector txsdata(block.vtx.size()); + CCheckQueueControl control(fScriptChecks && parallel_script_checks ? &m_chainman.GetCheckQueue() : nullptr); std::vector prevheights; CAmount nFees = 0;