What changed, and why it matters
This commit removes a helper function called all_targets_satisfied() from the peer-to-peer (p2p) message handling code. That function used to check whether every block header in a 'headers' message met its own proof-of-work target. The change is framed by the author as a design cleanup: p2p should only encode and decode network messages, while proof-of-work verification should be done by the caller or elsewhere. Removing the check does not by itself create a vulnerability, but any downstream code that relied on this function to validate headers before processing them will no longer get that protection automatically. Those callers must now add the check themselves or use a different validation path.
Review downstream consumers of HeadersMessage to confirm they perform proof-of-work validation explicitly after receiving headers messages. If the project intends to keep this check, it should be reintroduced in a caller-appropriate location and documented in release notes as a breaking API change.
Security signals we found
Removal of proof-of-work validation helper from p2p message parsing layer
Potential for downstream callers to lose an implicit security check if they do not migrate to explicit validation
No replacement validation logic added in the same commit
Evidence from the diff
The patch removes the import of bitcoin::block::HeaderExt and deletes HeadersMessage::all_targets_satisfied(), which iterated over each header, computed header.target(), and called header.validate_pow(target), returning false if any header failed. The corresponding unit-test assertion is also removed. The change decouples the p2p crate from bitcoin’s block-header extension trait and from proof-of-work validation logic. It is an API/behavior change, not a memory-safety or cryptographic bug fix.
Changed components
rust-bitcoin p2p cratep2p/src/message.rsHeadersMessageInspect captured patch +0 / −11
diff --git a/p2p/src/message.rs b/p2p/src/message.rs
index b501491c..82081b96 100644
--- a/p2p/src/message.rs
+++ b/p2p/src/message.rs
@@ -14,7 +14,6 @@ use core::{cmp, fmt};
#[cfg(feature = "arbitrary")]
use arbitrary::{Arbitrary, Unstructured};
-use bitcoin::block::HeaderExt;
use bitcoin::consensus::encode::{self, Decodable, Encodable, ReadExt, WriteExt};
use bitcoin::merkle_tree::MerkleBlock;
use bitcoin::{block, transaction};
@@ -1262,15 +1261,6 @@ impl HeadersMessage {
.zip(self.0.iter().skip(1))
.all(|(first, second)| first.block_hash().eq(&second.prev_blockhash))
}
-
- /// Each header passes its own proof-of-work target.
- pub fn all_targets_satisfied(&self) -> bool {
- !self.0.iter().any(|header| {
- let target = header.target();
- let valid_pow = header.validate_pow(target);
- valid_pow.is_err()
- })
- }
}
impl Decodable for HeadersMessage {
@@ -2127,6 +2117,5 @@ mod test {
).unwrap();
let headers_message = HeadersMessage(vec![block_900_000, block_900_001, block_900_002]);
assert!(headers_message.is_connected());
- assert!(headers_message.all_targets_satisfied());
}
}
Why this scored 34/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.