Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bidder Can Retrieve Bid Amount Twice in claimAuction #2029

Closed
c4-submissions opened this issue Nov 13, 2023 · 6 comments
Closed

Bidder Can Retrieve Bid Amount Twice in claimAuction #2029

c4-submissions opened this issue Nov 13, 2023 · 6 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-1323 partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%)

Comments

@c4-submissions
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/AuctionDemo.sol#L116-L130

Vulnerability details

Impact

This vulnerability enables a bidder to recover their bid amount twice during the execution of the claimAuction function.

Proof of Concept

A race condition between the claimAuction and cancelBid functions allows a non-winning bidder to claim their bid twice:

  • In claimAuction, the function proceeds if the auction has ended, as checked by require(block.timestamp >= minter.getAuctionEndTime(_tokenid)).
  • In cancelBid, the function is accessible as long as the auction hasn't ended, verified by require(block.timestamp <= minter.getAuctionEndTime(_tokenid), "Auction ended");.
  • A bidder's contract, in the line (bool success, ) = payable(auctionInfoData[_tokenid][i].bidder).call{value: auctionInfoData[_tokenid][i].bid}(""), can use its receive() function to re-enter the cancelBid function. This reentrancy can occur within the same block timestamp.
  • The bidder can thus bypass the require checks in cancelBid and reclaim their bid, effectively receiving their bid amount twice.

Tools Used

manual review

Recommended Mitigation Steps

Fix timing checks in claimAuction and cancelBid

Assessed type

Reentrancy

@c4-submissions c4-submissions added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Nov 13, 2023
c4-submissions added a commit that referenced this issue Nov 13, 2023
@c4-pre-sort
Copy link

141345 marked the issue as duplicate of #2039

@c4-pre-sort
Copy link

141345 marked the issue as duplicate of #51

@c4-pre-sort
Copy link

141345 marked the issue as not a duplicate

@c4-pre-sort
Copy link

141345 marked the issue as duplicate of #962

@c4-judge
Copy link

c4-judge commented Dec 4, 2023

alex-ppg marked the issue as duplicate of #1323

@c4-judge
Copy link

c4-judge commented Dec 8, 2023

alex-ppg marked the issue as partial-50

@c4-judge c4-judge added the partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%) label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-1323 partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%)
Projects
None yet
Development

No branches or pull requests

3 participants