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

_amount requires to be updated to contract balance increase #25

Closed
code423n4 opened this issue Apr 29, 2022 · 3 comments
Closed

_amount requires to be updated to contract balance increase #25

code423n4 opened this issue Apr 29, 2022 · 3 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-04-mimo/blob/b18670f44d595483df2c0f76d1c57a7bfbfbc083/core/contracts/inception/AdminInceptionVault.sol#L149-L154

Vulnerability details

Impact

Every time transferFrom or transfer function in ERC20 standard is called there is a possibility that underlying smart contract did not transfer the exact amount entered.
It is required to find out contract balance increase/decrease after the transfer.
This pattern also prevents from re-entrancy attack vector.

Proof of Concept

Tools Used

Recommended Mitigation Steps

Recommended code:
function deposit(address _collateralType, uint256 _amount) public override onlyOwner {
IERC20 asset = IERC20(_collateralType);

uint256 balanceBefore = asset.balanceOf(address(this)); // remembering asset balance before the transfer
asset.safeTransferFrom(msg.sender, address(this), _amount);
_amount = asset.balanceOf(address(this)) - balanceBefore; // updating actual _amount to the contract balance increase

asset.safeIncreaseAllowance(address(_a.core()), _amount);
_a.core().deposit(_collateralType, _amount);

}

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Apr 29, 2022
code423n4 added a commit that referenced this issue Apr 29, 2022
@m19 m19 added the duplicate This issue or pull request already exists label May 5, 2022
@m19
Copy link
Collaborator

m19 commented May 10, 2022

Duplicate of #156

@gzeoneth
Copy link
Member

gzeoneth commented Jun 5, 2022

I agree with the sponsor there doesn't seems to be a pathway for a fee-on-transfer token to not revert in every instance of transfer except for the one in DemandMinerV2, which in the doc stated:

Liquidity Mining V2
The next version of reward contracts for the users of the protocol. In the first iteration of liquidity mining contracts, users earned MIMO tokens on their debt and staked LP and PAR tokens.

where the LP and PAR tokens are not fee-on-transfer. Downgrading this to Low / QA.

@gzeoneth gzeoneth added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Jun 5, 2022
@gzeoneth
Copy link
Member

gzeoneth commented Jun 5, 2022

Consider with warden's' QA report #51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Projects
None yet
Development

No branches or pull requests

3 participants