DoS for EMPAM refundBid function when the number of bids is large.
Vulnerability Detail
The refundBid function in the EMPAM contract has a complexity of O(n) where n is the number of bids. This can be exploited to perform a DoS attack by creating a large number of bids and calling the refundBid function. The function will iterate over all the bids to find the bids to refund, which will consume a large amount of gas and cause the transaction to revert.
Impact
Users will not be able to request a refund for their bids.
shaka
medium
DoS for EMPAM
refundBid
Summary
DoS for EMPAM
refundBid
function when the number of bids is large.Vulnerability Detail
The
refundBid
function in theEMPAM
contract has a complexity of O(n) where n is the number of bids. This can be exploited to perform a DoS attack by creating a large number of bids and calling therefundBid
function. The function will iterate over all the bids to find the bids to refund, which will consume a large amount of gas and cause the transaction to revert.Impact
Users will not be able to request a refund for their bids.
Code Snippet
https://github.com/sherlock-audit/2024-03-axis-finance/blob/main/moonraker/src/modules/auctions/EMPAM.sol#L295-L301
Proof of concept
Add the following code to the contract
EmpaModuleRefundBidTest
inrefundBid.t.sol
and runforge test --mt test_refundBidOog
.Tool used
Manual Review
Recommendation
Implement a search of bids with O(1) complexity for the refund function.
Duplicate of #41