mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:50:37 +00:00
policy: reject invalid CFeeRate values when deserializing #36816
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36816
Loading…
Reference in a new issue
No description provided.
Delete branch "pr/feerate-unser"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem: With the
UnstableChainIPC interface from #29409 merged, an IPC client could makebitcoin-nodehit anAssumefailure (debug builds) or compute wrong fees (release builds) by passing a malformed feerate tobroadcastTransaction,calculateIndividualBumpFeesorcalculateCombinedBumpFee. These methods take feerates as serializedDatafields, andCFeeRatedeserialization reads the fee and size without the checks its constructors do, so it accepts a negative size, which fee calculations require to be positive, and a zero size with a nonzero fee, which compares as an infinite feerate. Nothing deserializes aCFeeRateon master today.Solution: Make
CFeeRatedeserialization throw on values its constructors cannot produce, the same way other malformed serialized data is rejected. The change is aSER_READcheck insrc/policy/feerate.hplus a unit test. It is similar to #36520, which handles other invalid arguments toChainIPC methods.This issue was found by Project Loupe and passed on by instagibbs.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.
Can the IPC client not still cause aborts via ftrapv or incorrect results, by just passing a feerate so large that it overflows later calculations?
No verified findings are available from this review.
Review coverage was incomplete.
Reviewed:
1c6060e7f675· Review report · Previous reportspermalink
re: https://github.com/bitcoin/bitcoin/pull/36816#issuecomment-6745849877
This might be possible, and if it is, it seems like the type of fix that would belong in #36520, which adds extra error checking to IPC methods, since it's not specific to the CFeeRate class and could happen with other numeric arguments.
Or if you're suggesting the problem here does not necessarily need to be solved, and it's ok for debug builds to crash and release builds to produce bad results if they are given bad values, maybe that could make sense too.
This PR is narrower: it only rejects serialized values that CFeeRate's constructors can't produce, like a negative size, which hits
Assume(size > 0)inFeeFrac::EvaluateFee. A feerate that's valid but too large for later calculations is a range problem, the same one RPC methods avoid by bounding feerates inParseFeeRate, so I'd check it where the IPC method receives the value.Ok, I see. Maybe turn this into a draft for now, given that it modifies dead/unreachable code and depends on https://github.com/bitcoin/bitcoin/pull/29409, which is not a draft, but again depends on https://github.com/bitcoin-core/libmultiprocess/pull/377?
Once the code is reachable, a small dummy test of the form https://github.com/bitcoin/bitcoin/pull/36093 could be added to this pull?