AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Moderate 60 Bitcoin

Merge bitcoin/bitcoin#36712: fees: prevent divide by zero in CFeeRate

Public commit record

What the developer wrote

Authored by merge-script

91/100 · Strong
Merge bitcoin/bitcoin#36712: fees: prevent divide by zero in CFeeRate

f442fa20d437f02518c327736206185bd6f6a1a1 fees: prevent divide by zero in CFeeRate (ismaelsadeeq)

Pull request description:

A CFeeRate with size 0 `GetFeePerK()` and `CFeeRate+=` evaluated `EvaluateFeeDown(1000)` unconditionally, dividing by that zero size and crashing.

Return 0 for an empty fee rate, matching `GetFee()` behaviour, and add minimal unit test coverage.

This was reported by Jacob F Cudney (aragondragon)

ACKs for top commit:
pablomartin4btc:
re-ACK f442fa20d437f02518c327736206185bd6f6a1a1
polespinasa:
re-ACK f442fa20d437f02518c327736206185bd6f6a1a1
musaHaruna:
Code review ACK [f442fa2](https://github.com/bitcoin/bitcoin/pull/36712/changes/f442fa20d437f02518c327736206185bd6f6a1a1)

Tree-SHA512: c3792271819814272a78845ce6f2782aa9ec629f2d67a1505c195bc340ea55e326b686b928b3958bd1cc807ca577747bd6ebe2e2cd3dc367e5cca1316a6b721d
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This commit fixes a divide-by-zero crash in Bitcoin Core's fee-rate calculation. When a transaction fee rate was created with a size of zero, calling certain methods would try to divide by zero and crash the program. The fix makes these methods safely return zero instead, matching the behavior of related code, and adds tests to prevent the crash from coming back.

Recommended action

Apply the patch. Review other CFeeRate arithmetic and comparison paths for similar zero-size assumptions, and ensure all call sites that may construct a zero-size rate handle the empty case safely.

Security signals we found

01

Divide-by-zero crash in CFeeRate::GetFeePerK() and CFeeRate::operator+=

02

Zero-size fee rate construction reachable in normal fee computations

03

Patch adds explicit empty-rate guard and unit tests

04

Crash could lead to denial of service if triggered on a node code path

Risk score

Why this scored 60/100

Our methodology →
Potential impact 18/30
Exploitability 12/25
Stealth signal 8/15
Affected reach 10/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.