settleAuction may be impossible if locked at a wrong time.
The settleAuction function calculates a new ratio by subtracting a time-dependent value from a base value, which can underflow if the bond is locked too late, causing the transaction to revert. An attacker could lock tokens at a time when the subtraction always fails, making the auction impossible to settle and potentially trapping funds.
Submitted by jonah1005
Impact
The auction contract decides a new ibRatio in the function settleAuction. Auction.sol#L89-L91
uint256 a = factory.auctionMultiplier() * basket.ibRatio();
uint256 b = (bondTimestamp - auctionStart) * BASE / factory.auctionDecrement();
uint256 newRatio = a - b;
In this equation, a would not always be greater than b. The auctionBonder may lock the token in bondForRebalance() at a point that a-b would always revert.
The contract should not allow users to lock the token at the point that not gonna succeed. Given the possible (huge) loss of the user may suffer, I consider this is a medium-risk issue.
Proof of Concept
Here’s a web3.py script to trigger this bug.
basket.functions.publishNewIndex([dai.address], [deposit_amount]).transact()
for i in range(4 * 60 * 24):
w3.provider.make_request('evm_mine', [])
basket.functions.publishNewIndex([dai.address], [deposit_amount]).transact()
print('auction on going', auction.functions.auctionOngoing().call())
for i in range(20000):
w3.provider.make_request('evm_mine', [])
all_token = basket.functions.balanceOf(user).call()
basket.functions.approve(auction.address, all_token).transact()
auction.functions.bondForRebalance().transact()
# error Log
# {'code': -32603, 'message': 'Error: VM Exception while processing transaction: reverted with panic code 0x11 (Arithmetic operation underflowed or overflowed outside of an unchecked block)'}
auction.functions.settleAuction([], [], [], [], []).transact()
Tools Used
None
Recommended Mitigation Steps
Recommend to calculate the new irate in bondForRebalance. I understand the auctionBonder should take the risk to get the profit. However, the contract should protect the user in the first place when this auction is doomed to fail.
frank-beard (Kuiper) confirmed
Alex the Entreprenerd (judge) commented:
I do not believe the users are at risk of a specific loss as they can always redeem their shares for underlying
Basket.burnHowever, this is still a valid finding, and the external conditions make medium severity appropriate
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 contract does not validate that the base value `a` is greater than the time-dependent value `b` before performing the subtraction, allowing an underflow when `b` exceeds `a`.
Impact
The auction may become impossible to settle, and the user who locked tokens could suffer a huge loss, though the judge noted users can still redeem shares for underlying assets via Basket.burn.
What the attacker needed
A user with tokens to bond; ability to time the bond transaction
The fix
The contract should calculate the new ratio in bondForRebalance and prevent locking tokens when the auction is doomed to fail.
How it was found
- Publish a new index to start an auction.
- Advance the blockchain time by mining many blocks.
- Approve the auction contract to spend the user's tokens.
- Call bondForRebalance to lock tokens, which reverts with an arithmetic underflow.
- Call settleAuction, which also fails because the bond is locked at an invalid time.
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.
In a smart contract, numbers have limits. If you subtract a larger number from a smaller one, the result wraps around to a huge number, which the contract treats as an error and cancels the transaction. Here, a user can lock their tokens at a moment when the subtraction will always fail, so the auction can never be completed.
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.