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

_depositAmount requires to be updated to contract balance increase #24

Closed
code423n4 opened this issue Apr 29, 2022 · 2 comments
Closed
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#L75-L89

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.

Proof of Concept

Tools Used

Recommended Mitigation Steps

Recommended code:
function depositAndBorrow(
address _collateralType,
uint256 _depositAmount,
uint256 _borrowAmount
) external override onlyOwner {
IERC20 asset = IERC20(_collateralType);

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

asset.safeIncreaseAllowance(address(_a.core()), _depositAmount);
_a.core().depositAndBorrow(_collateralType, _depositAmount, _borrowAmount);
if (_collateralId[_collateralType] == 0) {
    uint8 newId = ++_collateralCount;
    _collateralId[_collateralType] = newId;
    _collaterals[newId] = _collateralType;
}

}

@m19
Copy link
Collaborator

m19 commented May 10, 2022

Duplicate of #156

@m19 m19 marked this as a duplicate of #156 May 10, 2022
@m19 m19 closed this as completed May 10, 2022
@gzeoneth
Copy link
Member

gzeoneth commented Jun 5, 2022

Consider with warden's' QA report #51

@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
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