Malicious users can donate/leave dust amounts of collateral in contract during auctions to buy other collateral at very low prices
The auction contract only closes an auction when the collateral token balance reaches exactly zero, so an attacker can leave a tiny amount (dust) or donate a small amount to keep the auction open. This extends the auction and lets the attacker buy newly added collateral at heavily discounted prices.
0x3e84fa45 Follow with 0x52, rogue-lion-0619 and 1 other
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-04-hubble-exchange-judging/issues/168
Found by
0x3e84fa45, 0x52, rogue-lion-0619, ver0759
Summary
Auctions are only ended early if the amount of the token being auctioned drops to 0. This can be exploited via donation or leaving dust in the contract to malicious extend the auction and buy further liquidate collateral at heavily discounted prices.
Vulnerability Detail
function buyCollateralFromAuction(address token, uint amount) override external {
Auction memory auction = auctions[token];
// validate auction
require(_isAuctionOngoing(auction.startedAt, auction.expiryTime), "IF.no_ongoing_auction");
// transfer funds
uint vusdToTransfer = _calcVusdAmountForAuction(auction, token, amount);
address buyer = _msgSender();
vusd.safeTransferFrom(buyer, address(this), vusdToTransfer);
IERC20(token).safeTransfer(buyer, amount); // will revert if there wasn't enough amount as requested
// close auction if no collateral left
if (IERC20(token).balanceOf(address(this)) == 0) { <- @audit-issue only cancels auction if balance = 0
auctions[token].startedAt = 0;
}
}
When buying collateral from an auction, the auction is only closed if the balance of the token is 0. This can be exploited in a few ways to maliciously extend auctions and keep the timer (and price) decreasing. The first would be buy all but 1 wei of a token leaving it in the contract so the auction won't close. Since 1 wei isn't worth the gas costs to buy, there would be a negative incentive to buy the collateral, likely resulting in no on buying the final amount. A second approach would be to frontrun an buys with a single wei transfer with the same results.
Now that the auction has been extended any additional collateral added during the duration of the auction will start immediately well below the assets actual value. This allows malicious users to buy the asset for much cheaper, causing loss to the insurance fund.
Impact
Users can maliciously extend auctions and potentially get collateral for very cheap
Code Snippet
Tool used
Manual Review
Recommendation
Close the auction if there is less than a certain threshold of a token remaining after it has been bought:
IERC20(token).safeTransfer(buyer, amount); // will revert if there wasn't enough amount as requested
+ uint256 minRemainingBalance = 1 * 10 ** (IERC20(token).decimal() - 3);
// close auction if no collateral left
+ if (IERC20(token).balanceOf(address(this)) <= minRemainingBalance) {
auctions[token].startedAt = 0;
}
Discussion
asquare08
This issue can come when multi-collateral is enabled. Therefore, we will fix this with post-mainnet releases as we are launching mainnet with single collateral.
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
The auction closure condition checks for an exact zero balance instead of a small threshold, allowing dust or donations to keep the auction open.
Impact
Attackers could extend auctions and buy collateral at very low prices, causing a loss to the insurance fund.
What the attacker needed
Multi-collateral mode enabled; attacker can buy or transfer tokens to the contract
The fix
The auction should close when the remaining balance is below a small threshold, not only when it is exactly zero.
How it was found
- Buy all but 1 wei of the auctioned token, leaving a tiny balance in the contract.
- The auction does not close because the balance is not zero.
- Alternatively, front-run a buy with a 1 wei transfer to the contract to achieve the same effect.
- The auction timer and price continue to decrease.
- Any additional collateral added during the extended auction starts at a very low price.
- Buy the newly added collateral at a heavily discounted price.
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 collateral auction, the price drops over time until all the collateral is sold. The contract only stops the auction when the collateral balance is exactly zero. An attacker can leave a tiny amount (like 1 wei) or send a tiny amount to the contract, so the balance never hits zero and the auction keeps running. Then the attacker can buy any new collateral added during that extended time at a very low price.
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.