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

ERC20 transfer return value not checked #218

Closed
code423n4 opened this issue Sep 18, 2022 · 1 comment
Closed

ERC20 transfer return value not checked #218

code423n4 opened this issue Sep 18, 2022 · 1 comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists invalid This doesn't seem right 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/blob/bca5080635370424a9fe21fe1aded98345d1f723/src/Vault.sol#L167
https://github.com/code-423n4/2022-09-y2k-finance/blob/bca5080635370424a9fe21fe1aded98345d1f723/src/Vault.sol#L227
https://github.com/code-423n4/2022-09-y2k-finance/blob/bca5080635370424a9fe21fe1aded98345d1f723/src/Vault.sol#L230

Vulnerability details

Impact

According to EIP-20, transfer and transferFrom return a boolean success value. They can optionally revert when the tranfer does not succeed (which many tokens do), but this is no requirement. Vault does not check the return value of these calls. Because of that, it is possible to get free shares and steal assets from other users (when the withdrawal is performed).

Proof Of Concept

The vault is used with a token that does not revert when the transfer does not succeed. A user calls deposit without approving the smart contract. The asset transfer does not succeed, but this is not detected by the vault. Because of this, the user still receives the shares. He can then later call withdraw to get the corresponding amount for his shares, which in this case is taken from other users that deposited into this vault

Recommended Mitigation Steps

Use OpenZeppelins SafeTransfer library. This library also handles tokens correctly that do not return a value, which also exist.

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Sep 18, 2022
code423n4 added a commit that referenced this issue Sep 18, 2022
@3xHarry
Copy link
Collaborator

3xHarry commented Sep 22, 2022

dup #499

@3xHarry 3xHarry added duplicate This issue or pull request already exists disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) labels Sep 22, 2022
@HickupHH3 HickupHH3 added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Oct 18, 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
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists invalid This doesn't seem right unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

5 participants