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

Lack of support for fee-on-transfer and rebasing ERC20 token #75

Closed
code423n4 opened this issue Jan 27, 2023 · 2 comments
Closed

Lack of support for fee-on-transfer and rebasing ERC20 token #75

code423n4 opened this issue Jan 27, 2023 · 2 comments
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 nullified Issue is high quality, but not accepted

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc20Quest.sol#L86
https://github.com/rabbitholegg/quest-protocol/blob/8c4c1f71221570b14a0479c216583342bd652d8d/contracts/Erc20Quest.sol#L103

Vulnerability details

Impact

Lack of support for fee-on-transfer and rebasing ERC20 token

Proof of Concept

.In the current implementation, the code assume the transfered amount matches the receiving amount

quest-protocol\contracts\Erc20Quest.sol:
   66      function _transferRewards(uint256 amount_) internal override {
   67:         IERC20(rewardToken).safeTransfer(msg.sender, amount_);
   68      }

   85          uint256 nonClaimableTokens = IERC20(rewardToken).balanceOf(address(this)) - protocolFee() - unclaimedTokens;
   86:         IERC20(rewardToken).safeTransfer(to_, nonClaimableTokens);
   87      }

  102      function withdrawFee() public onlyAdminWithdrawAfterEnd {
  103:         IERC20(rewardToken).safeTransfer(protocolFeeRecipient, protocolFee());
  104      }

However, according to

https://github.com/d-xo/weird-erc20#fee-on-transfer

Some tokens take a transfer fee (e.g. STA, PAXG), some do not currently charge a fee but may do so in the future (e.g. USDT, USDC).

If the ERC20 charge transfer fee, the user cannot claim the fully amount of reward they are entitled.

According to

https://github.com/d-xo/weird-erc20#balance-modifications-outside-of-transfers-rebasing--airdrops

Some tokens may make arbitrary balance modifications outside of transfers (e.g. Ampleforth style rebasing tokens, Compound style airdrops of governance tokens, mintable / burnable tokens).

Because the smart contract does not have method to handle the rebased ERC20 token or different airdropped ERC20 token, which can lock a part of token in the smart contract.

Tools Used

Manual Review

Recommended Mitigation Steps

We recommend the protocol make it explicit in the doc that the fee-on-transfer and rebasing ERC20 token are not supported.

@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 Jan 27, 2023
@kirk-baird
Copy link

Closing as this seems to be exactly the same as #76

@c4-judge c4-judge closed this as completed Feb 5, 2023
@c4-judge
Copy link
Contributor

c4-judge commented Feb 5, 2023

kirk-baird marked the issue as nullified

@c4-judge c4-judge added the nullified Issue is high quality, but not accepted label Feb 5, 2023
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 nullified Issue is high quality, but not accepted
Projects
None yet
Development

No branches or pull requests

3 participants