Auctions succeeding condition does not take into account the claimable fees in the pool. It can result of a drastical reduction of claimable fees if auction succeeds, or cause an auction to fail if the fees are claimed
The auction success condition compares the total reserveToken bid to a percentage of the pool's balance but ignores claimable fees. An attacker could cause a drastic reduction in claimable fees when an auction succeeds, or cause an auction to fail if fees are claimed before ending.
Source: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/891
Found by
0xadrii, BADROBINX, Boy2000, Strapontin, bladeee, copperscrewer, i3arba, komane007, phoenixv110, shiazinho, t0x1c, y4y
Summary
One of the condition for an auction to succeed is to have the total bet of reserveToken be less than or equal to 90% (or higher, set by admin) of the pool's balance to ensure tokens are transfered.
This calculation does not take into account the amount of fees claimable by the beneficiary, and can result in two issues :
-
When an auction succeeds, it gets from the pool the amount of tokens users bet. This will drastically reduce the fees claimable from the beneficiary as it lowers the pool's balance, which is linked to fees calculation.
-
If an auction should succeed by having the total of reserveToken bid being on the lower edge of the 90% of pool's token amount, and the fees are claimed, then the auction may fail if the reserveToken bid become higher than the newly calculated 90% to tokens in the pool.
Root Cause
Auction does not includes the claimable fees when calculating the reserve amount it can receive
Internal Pre-conditions
No response
External Pre-conditions
No response
Attack Path
Attack path 1
- An auction is created and the condition for it to succeed are met (with an average total amount of
reserveTokenbid) - The amount of fees claimable are equal to X
- The function
Auction::endAuctionis called and the auction succeeds, takingreserveTokenfrom the pool - The amount of fees claimable are now lower than X
Attack path 2
- An auction is created and the condition for it to succeed are met (with a high total amount of
reserveTokenbid, near 90%) - The fees are claimed
- The function
Auction::endAuctionis called and the auction ends in the stateFAILED_POOL_SALE_LIMITbecause the bids are higher than allowed amount ofreserveToken
Impact
Drastic reduction of fees claimable and potential auction ending in an unsuccessful state
PoC
To get the amount of fees claimable from the pool, set the visibility of the function
Pool::getFeeAmountto public
Copy this poc in Auction.t.sol and run it
// forge test --mt test_auction_fees_1 -vvv
function test_auction_fees_1() public {
// We need to set the poolSaleLimit to 90% because it is set to 110% in the setUp
uint256 poolSaleLimitSlot = 6;
vm.store(address(auction), bytes32(poolSaleLimitSlot), bytes32(uint256(90)));
console.log(auction.poolSaleLimit());
// Set the fees at 10%
vm.prank(governance);
Pool(pool).setFee(100000);
uint256 maxUSDCToBid = auction.totalBuyCouponAmount();
// If we go beyond this value, endAuction will end in a failed state (FAILED_POOL_SALE_LIMIT)
uint256 maxReserveTokenClaimable =
(IERC20(auction.sellReserveToken()).balanceOf(pool) * auction.poolSaleLimit()) / 100;
// 1. The auction can succeed, and will rewards users for half of the pool's claimable amount
vm.startPrank(bidder);
usdc.mint(bidder, maxUSDCToBid);
usdc.approve(address(auction), maxUSDCToBid);
auction.bid(maxReserveTokenClaimable / 2, maxUSDCToBid);
vm.stopPrank();
vm.warp(auction.endTime());
// 2. Amount of fees claimable are equal to X
// Set `getFeeAmount` to public to see its result value
uint256 claimableFeesBefore = Pool(pool).getFeeAmount();
console.log("claimableFeesBefore", claimableFeesBefore);
// 3. `endAuction` put the auction in the succeed state
auction.endAuction();
assert(Auction.State.SUCCEEDED == auction.state());
// 4. The amount of fees claimable are now lower than X
uint256 claimableFeesAfter = Pool(pool).getFeeAmount();
console.log("claimableFeesAfter ", claimableFeesAfter);
assert(claimableFeesBefore > claimableFeesAfter);
}
// forge test --mt test_auction_fees_2 -vvv
function test_auction_fees_2() public {
// We need to set the poolSaleLimit to 90% because it is set to 110% in the setUp
uint256 poolSaleLimitSlot = 6;
vm.store(address(auction), bytes32(poolSaleLimitSlot), bytes32(uint256(90)));
console.log(auction.poolSaleLimit());
// Set the fees at 10%
vm.startPrank(governance);
Pool(pool).setFee(100000);
Pool(pool).setFeeBeneficiary(governance);
vm.stopPrank();
uint256 maxUSDCToBid = auction.totalBuyCouponAmount();
// If we go beyond this value, endAuction will end in a failed state (FAILED_POOL_SALE_LIMIT)
uint256 maxReserveTokenClaimable = (IERC20(auction.sellReserveToken()).balanceOf(pool) * auction.poolSaleLimit()) / 100;
// 1. The auction can succeed, and will rewards users for almost the pool's claimable amount
vm.startPrank(bidder);
usdc.mint(bidder, maxUSDCToBid);
usdc.approve(address(auction), maxUSDCToBid);
auction.bid(maxReserveTokenClaimable - 10, maxUSDCToBid);
vm.stopPrank();
vm.warp(auction.endTime());
// 2. The fees are claimed
vm.prank(governance);
Pool(pool).claimFees();
// 3. Ending the auction fails it
auction.endAuction();
assert(Auction.State.FAILED_POOL_SALE_LIMIT == auction.state());
// Note that without the governance claiming fees, the auction would succeed
}
Running them produces the following output :
$ forge test --mt test_auction_fees_1 -vvv
[⠰] Compiling...
[⠒] Compiling 14 files with Solc 0.8.27
[⠰] Solc 0.8.27 finished in 24.60s
Compiler run successful!
Ran 1 test for test/Auction.t.sol:AuctionTest
[PASS] test_auction_fees_1() (gas: 448008)
Logs:
90
claimableFeesBefore 1369863013698630136986301369
claimableFeesAfter 753424657534246575342465753
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 19.26ms (2.42ms CPU time)
Ran 1 test suite in 42.30ms (19.26ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)
...
$ forge test --mt test_auction_fees_2 -vvv
[⠰] Compiling...
No files changed, compilation skipped
Ran 1 test for test/Auction.t.sol:AuctionTest
[PASS] test_auction_fees_2() (gas: 467880)
Logs:
90
Suite result: ok. 1 passed; 0 failed; 0 skipped; finished in 19.09ms (2.16ms CPU time)
Ran 1 test suite in 39.14ms (19.09ms CPU time): 1 tests passed, 0 failed, 0 skipped (1 total tests)
Mitigation
Include the claimable fees when calculating the total sell token limit at the end of an auction, or allocate an amount of tokens for an auction when the auction is created.
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/Convexity-Research/plaza-evm/pull/164
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 auction's success condition uses the pool's current balance without accounting for the claimable fees that are part of that balance.
Impact
Claimable fees could be drastically reduced, and an auction that should succeed may end in a failed state if fees are claimed first.
What the attacker needed
Auction created and bids placed; fees claimable by beneficiary; governance claims fees before auction ends
The fix
The protocol team fixed this issue by including claimable fees in the calculation or allocating tokens for the auction at creation.
How it was found
- Create an auction and meet the success condition with an average total reserveToken bid.
- Note the amount of claimable fees (X).
- Call endAuction; the auction succeeds and takes reserveToken from the pool.
- Observe that the claimable fees are now lower than X.
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 checks that the total amount bid is not too large compared to the pool's balance. But the pool also holds fees that can be claimed later. Because the check ignores those fees, an auction can succeed and then the fees become much smaller, or if fees are claimed first, the auction can fail even though it should have succeeded.
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.