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

M01 TOKEN TRANSFERS DO NOT VERIFY THAT THE TOKENS WERE SUCCESSFULLY TRANSFERRED #12

Closed
code423n4 opened this issue Sep 15, 2022 · 1 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 invalid This doesn't seem right sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-09-y2k-finance/tree/main/src/SemiFungibleVault.sol#L99
https://github.com/code-423n4/2022-09-y2k-finance/tree/main/src/SemiFungibleVault.sol#L127
https://github.com/code-423n4/2022-09-y2k-finance/tree/main/src//rewards/StakingRewards.sol#L99
https://github.com/code-423n4/2022-09-y2k-finance/tree/main/src//rewards/StakingRewards.sol#L122
https://github.com/code-423n4/2022-09-y2k-finance/tree/main/src//rewards/StakingRewards.sol#L136
https://github.com/code-423n4/2022-09-y2k-finance/tree/main/src//rewards/StakingRewards.sol#L221
https://github.com/code-423n4/2022-09-y2k-finance/tree/main/src/SemiFungibleVault.sol#L94
https://github.com/code-423n4/2022-09-y2k-finance/tree/main/src/SemiFungibleVault.sol#L127

Vulnerability details

problem

Some tokens (like zrx) do not revert the transaction when the transfer/transferfrom fails and return false, which requires us to check the return value after calling the transfer/transferfrom function.

In the purchase functions of MiniSales and TokenShop contracts, if _paymentToken is such a token, the user can purchase _saleToken and NFT without spending any tokens.

In the claim function of the Vesting contract, if _token is such a token, the user may lose his vested tokens.

prof

src/SemiFungibleVault.sol, 94, b' asset.safeTransferFrom(msg.sender, address(this), assets);'
src/SemiFungibleVault.sol, 127, b' asset.safeTransfer(receiver, assets);'
src/rewards/StakingRewards.sol, 99, b' stakingToken.safeTransferFrom('
src/rewards/StakingRewards.sol, 122, b' stakingToken.safeTransferFrom('
src/rewards/StakingRewards.sol, 136, b' rewardsToken.safeTransfer(msg.sender, reward);'
src/rewards/StakingRewards.sol, 221, b' ERC20(tokenAddress).safeTransfer(owner, tokenAmount);'
src/SemiFungibleVault.sol, 94, b' asset.safeTransferFrom(msg.sender, address(this), assets);'
src/SemiFungibleVault.sol, 127, b' asset.safeTransfer(receiver, assets);'

mitigation

We should check the return value of the function.

@code423n4 code423n4 added 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 labels Sep 15, 2022
code423n4 added a commit that referenced this issue Sep 15, 2022
@MiguelBits MiguelBits added the duplicate This issue or pull request already exists label Sep 30, 2022
@MiguelBits MiguelBits added resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") invalid This doesn't seem right and removed duplicate This issue or pull request already exists resolved Finding has been patched by sponsor (sponsor pls link to PR containing fix) sponsor confirmed Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity") labels Sep 30, 2022
@liveactionllama liveactionllama added sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue and removed invalid This doesn't seem right labels Oct 3, 2022
@HickupHH3
Copy link
Collaborator

dup #499

@HickupHH3 HickupHH3 added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Oct 29, 2022
@JeeberC4 JeeberC4 added the invalid This doesn't seem right label Nov 9, 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 invalid This doesn't seem right sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

5 participants