Skip to content

Commit

Permalink
Security: Replace queued checkpoint blocks with duplicate hashes
Browse files Browse the repository at this point in the history
We don't check the authorizing data hash until checkpoint blocks reach the state.

So signatures, proofs, or scripts could be different,
even if the block hash is the same.
  • Loading branch information
teor2345 committed Aug 30, 2021
1 parent 52cef8c commit c17baba
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions zebra-consensus/src/checkpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,23 @@ where
.entry(height)
.or_insert_with(|| QueuedBlockList::with_capacity(1));

// Replace older requests by newer ones by swapping the oneshot.
// Replace older requests with newer ones.
// The newer block is ok, the older block is an error.
for qb in qblocks.iter_mut() {
if qb.block.hash == hash {
let e = VerifyCheckpointError::NewerRequest { height, hash };
tracing::trace!(?e, "failing older of duplicate requests");
let old_tx = std::mem::replace(&mut qb.tx, new_qblock.tx);
let _ = old_tx.send(Err(e));

// ## Security
//
// Replace the entire queued block.
//
// We don't check the authorizing data hash until checkpoint blocks reach the state.
// So signatures, proofs, or scripts could be different,
// even if the block hash is the same.

let old = std::mem::replace(qb, new_qblock);
let _ = old.tx.send(Err(e));
return Ok(req_block);
}
}
Expand Down

0 comments on commit c17baba

Please sign in to comment.