Basket.sol#handleFees() could potentially cause disruption of minting and burning
The fee calculation in handleFees() multiplies the elapsed time by the licence fee without capping the result, so a large enough fee or a long enough idle period makes the computed percentage exceed the base constant. This causes an arithmetic underflow that reverts, blocking minting and burning of the basket token until the publisher lowers the fee.
Submitted by WatchPug
function handleFees() private {
if (lastFee == 0) {
lastFee = block.timestamp;
} else {
uint256 startSupply = totalSupply();
uint256 timeDiff = (block.timestamp - lastFee);
uint256 feePct = timeDiff * licenseFee / ONE_YEAR;
uint256 fee = startSupply * feePct / (BASE - feePct);
_mint(publisher, fee * (BASE - factory.ownerSplit()) / BASE);
_mint(Ownable(address(factory)).owner(), fee * factory.ownerSplit() / BASE);
lastFee = block.timestamp;
uint256 newIbRatio = ibRatio * startSupply / totalSupply();
ibRatio = newIbRatio;
emit NewIBRatio(ibRatio);
}
}
timeDiff * licenseFee can be greater than ONE_YEAR when timeDiff and/or licenseFee is large enough, which makes feePct to be greater than BASE so that BASE - feePct will revert on underflow.
Impact
Minting and burning of the basket token are being disrupted until the publisher update the licenseFee.
Proof of Concept
- Create a basket with a
licenseFeeof1e19or 1000% per year and mint 1 basket token; - The basket remain inactive (not being minted or burned) for 2 months;
- Calling
mintandburnreverts athandleFees().
Recommended Mitigation Steps
Limit the max value of feePct.
frank-beard (Kuiper) confirmed
Alex the Entreprenerd (judge) commented:
The finding is valid, there are conditions that would cause
feePctto be greater thanBASEThe conditions to trigger this seem to be:
- Wait enough time
- Have a high enough fee
Because this can happen under specific conditions, I will grade this finding as medium severity:
I would highly recommend the sponsor to consider the possibility of capping the
licenseFeeto make it easier to predict cases in which the operation can revert
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 percentage is computed as elapsed time times licence fee divided by a year without any upper bound, so it can exceed the base constant and underflow on subtraction.
Impact
Minting and burning of the basket token are disrupted until the publisher updates the licence fee; the judge graded this medium severity because it only happens under specific conditions.
What the attacker needed
Publisher sets a very high licence fee; basket stays idle long enough; no cap on feePct in contract
The fix
The fee percentage should be capped, and the judge recommended capping the licence fee so reverting cases are easier to predict.
How it was found
- Create a basket with a licence fee of 1000% per year and mint one basket token
- Leave the basket inactive for two months
- Call mint or burn and observe the revert inside handleFees()
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 keeps a running fee that grows with time since the last update. The code works out a percentage from the time passed and the configured fee rate, then subtracts it from a fixed base number. If that percentage grows larger than the base, the subtraction goes below zero, which Solidity treats as an error and cancels the whole transaction, so users can no longer create or redeem tokens.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.