Fee calculation is slightly off
The fee calculation uses a simple interest formula that does not compound, so collecting fees more frequently results in slightly less total fee than collecting less frequently. An attacker could exploit this by triggering frequent fee collections to reduce the amount paid.
Submitted by gzeon
The fee calculation
uint256 timeDiff = (block.timestamp - lastFee);
uint256 feePct = timeDiff * licenseFee / ONE_YEAR;
uint256 fee = startSupply * feePct / (BASE - feePct);
tries to calculate a fee such that fee/(supply+fee) = %fee using a simple interest formula (i.e. no compounding), this lead to slightly less fee collected when fee are collected more frequently (small timeDiff) vs less frequently (big timeDiff).
Proof of Concept
frank-beard (Kuiper) acknowledged, but disagreed with Medium severity and commented:
While this is technically true, the actual precision loss should be very negligible.
0xleastwood (judge) commented:
I think any precision loss or value leakage qualifies for a
mediumseverity issue. This seems like it would lead to an inconsistent fee calculation and is probably worthwhile fixing long-term.
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 fee formula uses simple interest instead of compound interest, causing precision loss when time intervals are small.
Impact
The precision loss is very negligible according to the developer, but the judge considered it a medium severity issue because it leads to inconsistent fee calculation and value leakage.
What the attacker needed
Ability to trigger fee collection
The fix
The fee calculation should be adjusted to use compound interest or otherwise ensure consistent fees regardless of collection frequency.
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.
A smart contract charges a fee based on how much time has passed since the last fee was taken. The formula used is like simple interest, which doesn't account for compounding. If fees are taken very often, the total fee ends up a tiny bit lower than if taken rarely, so someone could deliberately trigger frequent fee collections to pay less.
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.