Dynamic fee algorithm doesn't check for zero fee
The dynamic fee algorithm in Monero can return a zero minimum fee per byte due to rounding down instead of up. An attacker could spam the network until the median block weight is high enough, then send zero-fee transactions indefinitely, causing unlimited blockchain growth.
- Triaged in 22 hours
- Fixed in 3 months
- Disclosed after 2.0 years
Summary:
Dynamic fee algorithm Blockchain::get_dynamic_base_fee calculates the minimal fee per byte from current median block weight and block reward. The comment in the code says // min_fee_per_byte = round_up( 0.95 * block_reward * ref_weight / (fee_median^2) ), so it's supposed to round up the result of the division and never return 0 because the argument of round_up is always > 0. But the actual code rounds down when doing divisions and can return min_fee_per_byte = 0.
Releases Affected:
All current versions of Monero (v0.18.x.x)
Steps To Reproduce:
An attacker could spam the network with transactions until median block weight reaches 42426407 or bigger, at which point Blockchain::get_dynamic_base_fee will return 0, allowing 0-fee transactions to be included in mempool and mined. After that, the transaction flood attack will have 0 cost and can continue indefinitely.
Possible solution
Blockchain::get_dynamic_base_fee can check for 0 and return min_fee_per_byte = 1 to avoid this problem. Since it's not a part of consensus, it can be changed in a point release.
Impact
An attacker can eventually flood XMR network with transactions essentially for free, resulting in unlimited blockchain growth.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the code uses integer division that rounds down, while the intended formula requires rounding up, so the result can be zero when it should be positive.
Impact
An attacker could flood the XMR network with essentially free transactions, leading to unlimited blockchain growth.
What the attacker needed
Ability to spam the network with transactions; median block weight reaches 42426407 or higher
The fix
The function should check for zero and return a minimum fee per byte of 1; since it is not part of consensus, this can be changed in a point release.
How it was found
- Spam the network with transactions until the median block weight reaches 42426407 or higher.
- At that point, the dynamic fee function returns zero, allowing zero-fee transactions into the mempool and blocks.
- Continue flooding the network with zero-cost transactions indefinitely.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Monero is a cryptocurrency that adjusts transaction fees based on network congestion. The code that calculates the minimum fee has a rounding mistake: it rounds down instead of up, so under certain conditions the fee becomes zero. This means an attacker could flood the network with free transactions, making the blockchain grow without cost.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.