Attacker can forbid users to get refunded if sends enough bids on the EMPAM module
An attacker can send many minimum-value bids to an auction, causing the refund function to loop through all bids and run out of gas for later users. This prevents legitimate users from refunding their bids, potentially leading to loss of funds.
0xR360 Follow with 0xmuxyz, FindEverythingX and 1 other
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-03-axis-finance-judging/issues/41
Found by
0xR360, 0xmuxyz, FindEverythingX, shaka
Summary
When an auction starts an attacker can send enough encrypted bids to make future users that bid unable to be refunded.
Vulnerability Detail
An attacker can send valid bids with amounts equal to the minimum allowed amount for a bid. If enough bids are sent, users that bid after him won't be able to get refunded if they want to. Scenario:
- Attacker sends lots of bids just after auction creation.
- User sends bids
- User wants to refund some of them: The _refundBid function on the EMPAM module loops through all the bids to find the requested one, then pops it out of the decryption array. If there are too many bids before the one we are looking fur, gas can run out.
Impact
Breaks the refund functionality. User won't be able to refund bid. Possible loss of funds.
Code Snippet
Putting this test on the EMPA refund bid tests file can show how its performed.
function test_audit_dos_bids() public givenLotIsCreated givenLotHasStarted givenBidIsCreated(2e18, 1e18){
uint bidNums = 60000;
//worst case scenario for attack is: max limit for block, only tx in the block. This doesnt take in account the gas spent on entrypoint.
uint ETH_GAS_LIMIT = 30_000_000;
// attacker bids
for (uint i=0;i < bidNums; i++)
_createBid(1e18, 1e18); //amount can be as small as possible
uint64 normalUserBid = _createBid(2e18, 1e18);
uint256 gasBefore = gasleft();
vm.prank(address(_auctionHouse));
uint256 refundAmount = _module.refundBid(_lotId, normalUserBid, _BIDDER);
uint256 gasAfter = gasleft();
uint256 gasUsed = gasBefore - gasAfter;
assertEq(gasUsed > ETH_GAS_LIMIT,true, "out of gas");
}
Tool used
Manual Review
Recommendation
Instead of looping through each bidId, holding the index position of a non encrypted bid on a mapping should solve it. The mapping should be from bidId to its position in the array. When a bid is refunded, this position should also be changed for its replacement.
Discussion
nevillehuang
Believe #41 and #237 to not be duplicates based on different fix and code logic involved for (refunding/decrypting/settling mechanisms)
The fix isn't the same because we need to remove a loop from the refundBid function. The settle fix involves refactoring to allow a multi-txn process or decreasing the gas cost of it. Not really a good way to remove the loop from settle
sherlock-admin4
The protocol team fixed this issue in the following PRs/commits: https://github.com/Axis-Fi/moonraker/pull/145
10xhash
The protocol team fixed this issue in the following PRs/commits: Axis-Fi/moonraker#145
Fixed Now the index of the bid to be refunded is passed avoiding the iteration of the entire list.
sherlock-admin4
The Lead Senior Watson signed off on the fix.
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 refund function iterates over all bids to find the one to refund, which can exceed the block gas limit if there are too many bids.
Impact
Users may be unable to refund their bids, potentially leading to loss of funds.
What the attacker needed
Attacker can place many minimum-value bids; victim places a bid after the attacker's bids
The fix
The protocol team fixed this issue by passing the index of the bid to be refunded, avoiding iteration over the entire list.
How it was found
- Attacker sends many bids with the minimum allowed amount immediately after auction creation.
- A legitimate user places bids.
- The user tries to refund a bid, but the refund function loops through all bids and runs out of gas.
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 blockchain auction, users place bids and can later get their money back if they change their mind. The refund process checks all previous bids one by one, which costs gas (a fee for computation). An attacker can flood the auction with many tiny bids, making the refund check too expensive to complete, so later users cannot get their refunds.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.