Calls inside a loop might lead to a denial-of-service attack. #1855
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
duplicate-1785
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L112
https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L139
https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L113
https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L116
Vulnerability details
Impact
A call inside a loop is a situation where a function iterates over a collection of elements, and makes an external call to another contract for each element. An external call is a low-level interface that allows a contract to interact with another contract, such as call, delegatecall, staticcall, or transfer.
Proof of Concept
The issue with calls inside a loop is that they can lead to a denial-of-service attack, which is a type of attack that aims to make a contract unresponsive, unavailable, or fail to execute its logic. This can happen for several reasons.
Source of code:- https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L112
'''
IERC721(gencore).safeTransferFrom(ownerOfToken, highestBidder, _tokenid);
'''
Source of code:- https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L113
'''
(bool success, ) = payable(owner()).call{value: highestBid}("");
'''
Source of code:- https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L116
'''
(bool success, ) = payable(auctionInfoData[_tokenid][i].bidder).call{value: auctionInfoData[_tokenid][i].bid}("");
'''
Source of code:- https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L139
'''
(bool success, ) = payable(auctionInfoData[_tokenid][i].bidder).call{value: auctionInfoData[_tokenid][i].bid}("");
'''
Tools Used
Manual
Recommended Mitigation Steps
favoring the pull over push strategy for external calls, which is a best practice to prevent denial-of-service attacks. The pull over push strategy consists of two steps:
Assessed type
call/delegatecall
The text was updated successfully, but these errors were encountered: