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

The last bidder can't get fund back when quote token has transfer fee #87

Closed
code423n4 opened this issue Nov 7, 2022 · 3 comments
Closed
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 downgraded by judge Judge downgraded the risk level of this issue duplicate-47 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

code423n4 commented Nov 7, 2022

Lines of code

https://github.com/code-423n4/2022-11-size/blob/main/src/SizeSealed.sol#L164

Vulnerability details

Impact

In 'bid()' function, there is no security check if the actual received token is equal to 'quoteAmount' . When the quote token has transfer fee, the last bidder won't be able to get refund.

function bid(
    // ...
) external atState(idToAuction[auctionId], States.AcceptingBids) returns (uint256) {
    // ...

    EncryptedBid memory ebid;
    ebid.quoteAmount = quoteAmount;
    // ...
    a.bids.push(ebid);

    SafeTransferLib.safeTransferFrom(ERC20(a.params.quoteToken), msg.sender, address(this), quoteAmount); 
    // ...
}

Proof of Concept

Given

quoteToken = $TKN
fee = 5%
initBalanceOfContract = 0 $TKN

Bidder A bids with 100 $TKN, then

ebidA.quoteAmount = 100 $TKN
balanceOfContract = 100 $TKN * 95% = 95 $TKN

Bidder B bids with 100 $TKN, then

ebidB.quoteAmount = 100 $TKN
balanceOfContract = 95 $TKN + 100 $TKN * 95% = 190 $TKN

Bidder A cancels bid

ebidA.quoteAmount = 100 $TKN - 100 $TKN = 0 $TKN
balanceOfContract = 190 $TKN - 100 $TKN = 90 $TKN

Bidder B cancels bid

ebidB.quoteAmount = 100 $TKN - 100 $TKN = 0 $TKN
balanceOfContract = 90 $TKN - 100 $TKN = ??? // Failed

Tools Used

VS Code

Recommended Mitigation Steps

Revert if the actual received token is not equal to 'quoteAmount'.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Nov 7, 2022
code423n4 added a commit that referenced this issue Nov 7, 2022
@code423n4 code423n4 changed the title The last bider can't get refund when quote token with transfer fee The last bidder can't get refund when quote token has transfer fee Nov 7, 2022
@code423n4 code423n4 changed the title The last bidder can't get refund when quote token has transfer fee The last bidder can't get fund back when quote token has transfer fee Nov 7, 2022
@c4-judge c4-judge closed this as completed Nov 9, 2022
@c4-judge
Copy link
Contributor

c4-judge commented Nov 9, 2022

0xean marked the issue as duplicate

@c4-judge
Copy link
Contributor

c4-judge commented Dec 6, 2022

0xean marked the issue as satisfactory

@c4-judge c4-judge added satisfactory satisfies C4 submission criteria; eligible for awards 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Dec 6, 2022
@c4-judge
Copy link
Contributor

c4-judge commented Dec 6, 2022

0xean changed the severity to 2 (Med Risk)

@c4-judge c4-judge added the downgraded by judge Judge downgraded the risk level of this issue label Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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 downgraded by judge Judge downgraded the risk level of this issue duplicate-47 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

3 participants