Skip to content

[BFT-BUG] CRIT-BFT-2: PREPARE/COMMIT accept mismatched digests — equivocation attack - #2087

Closed
ArokyaMatthew wants to merge 1 commit into
Scottcjn:mainfrom
ArokyaMatthew:bft-bug/crit2-digest-not-validated
Closed

ArokyaMatthew wants to merge 1 commit into
Scottcjn:mainfrom
ArokyaMatthew:bft-bug/crit2-digest-not-validated

Conversation

@ArokyaMatthew

Copy link
Copy Markdown
Contributor

Vulnerability Class

Critical — BFT equivocation via digest mismatch (200 RTC bounty)

The Bug

handle_prepare() and handle_commit() verify HMAC signatures but never check that msg.digest matches the PRE-PREPARE proposal's digest. Each handler stores whatever digest the remote peer sends and counts it toward quorum.

Attack Vector

A Byzantine node sends PREPARE/COMMIT with a different digest than the leader's proposal:

# Honest leader proposes digest "abc123..." for epoch 500
# Byzantine node-D sends PREPARE with digest "xyz789..."
# Both count toward quorum → conflicting proposals can be "agreed upon"

This breaks the core PBFT safety invariant: all honest nodes in the quorum must agree on the same proposal content.

Fix
After signature verification in both handlers, compare msg.digest against pre_prepare_log[epoch].digest. Reject with a warning if they differ.

if epoch in self.pre_prepare_log:
    expected_digest = self.pre_prepare_log[epoch].digest
    if msg.digest != expected_digest:
        logging.warning(f"Digest mismatch from {msg.node_id}")
        return

All 5 tests pass.

Files Changed
node/rustchain_bft_consensus.py — digest validation in handle_prepare() + handle_commit()
node/test_bft_digest_validation.py — NEW test file (5 tests)
Ref: Bounty #2819
Wallet: aroky-x86-miner

…vocation attack

handle_prepare() and handle_commit() verify HMAC signatures but never
check that msg.digest matches the digest from the PRE-PREPARE proposal.
A Byzantine node can send PREPARE/COMMIT for a different digest than
what the leader proposed, and it still counts toward quorum.
This breaks the core PBFT safety guarantee: honest nodes could finalize
a proposal that not all of them agreed on, or Byzantine nodes could
vote for conflicting proposals simultaneously.
Fix: After signature verification, compare msg.digest against
pre_prepare_log[epoch].digest. Reject if they differ.
Tests added (new file test_bft_digest_validation.py):
- test_prepare_matching_digest_accepted
- test_prepare_wrong_digest_rejected
- test_commit_matching_digest_accepted
- test_commit_wrong_digest_rejected
- test_equivocation_cannot_reach_quorum
All 5 tests pass.
Bounty: Scottcjn#2819 (Critical, 200 RTC)
@github-actions

github-actions Bot commented Apr 5, 2026

Copy link
Copy Markdown
Contributor

Welcome to RustChain! Thanks for your first pull request.

Before we review, please make sure:

  • Your PR has a BCOS-L1 or BCOS-L2 label
  • New code files include an SPDX license header
  • You've tested your changes against the live node

Bounty tiers: Micro (1-10 RTC) | Standard (20-50) | Major (75-100) | Critical (100-150)

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/M PR: 51-200 lines labels Apr 5, 2026
@Scottcjn

Scottcjn commented Apr 5, 2026

Copy link
Copy Markdown
Owner

Good independent discovery, @ArokyaMatthew. The digest validation fix is correct.

However, this overlaps with @createkr's #2082 which covers the same PREPARE/COMMIT digest validation plus additional hardening (TTL freshness checks, commit view validation, and quorum defense-in-depth filtering). Since #2082 is more comprehensive and touches the same code paths, I'm merging that one and closing this as duplicate.

Payment: 25 RTC (independent discovery credit — you found the same BFT equivocation vector independently, which validates the severity)

Closing in favor of #2082.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) node Node server related size/M PR: 51-200 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants