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

Support of different ERC20 tokens #119

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

Support of different ERC20 tokens #119

code423n4 opened this issue Sep 17, 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/blob/main/src/Vault.sol#L167

Vulnerability details

Impact

The current version of the codebase does not handle special cases of tokens, e.g. deflationary, rebasing, or those that return true/false on success (see: https://github.com/d-xo/weird-erc20). Function purchase transfers tokens from msg.sender but it does not check the return value, nor how many tokens were actually transferred:

Proof of Concept

https://github.com/code-423n4/2022-09-y2k-finance/blob/main/src/Vault.sol#L167

  'asset.transferFrom(msg.sender, address(this), shares);'

Tools Used

manul code review

Recommended Mitigation Steps

I have 2 suggestions here:

  1. Use SafeERC20 library to handle token transfers: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/utils/SafeERC20.sol
  2. Consider checking the actual balances transferred (balance after-before) or clearly documenting that you do not support deflationary / rebasing / etc tokens.
@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 17, 2022
code423n4 added a commit that referenced this issue Sep 17, 2022
@MiguelBits MiguelBits added the invalid This doesn't seem right label 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 of #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