Steadefi

Steadefi
DeFiHardhatFoundryOracle
35,000 USDC
View results
Submission Details
Severity: medium
Invalid

Funds of a Victim User can be locked into Trove for compounding by a malicious User without permission

Summary

Post deposit operations if adding liquidity has been cancelled by GMX, then processDepositCancellation is called to repay borrowed assets and also to return user's deposited asset. This can be stopped by a malicious User by depositing some funds using GMXDeposit.sol::deposit.

Vulnerability Details

Post deposit, if the adding liquidity has been cancelled by GMX, then processDepositCancellation is called by keeper at :
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/strategy/gmx/GMXVault.sol#L366C1-L370C5

/**
* @notice Post deposit operations if adding liquidity has been cancelled by GMX
* @dev To be called only after deposit()/depositNative() is called
* @dev Should be called by approved vault's Callback or approved Keeper
*/
function processDepositCancellation() external onlyKeeper {
GMXDeposit.processDepositCancellation(_store);
}

to do the necessary as said above. But if a malicious actor frontruns the Keeper to deposit a small amount of token into the same Vault , it would lead to sweepage of USER funds present in the contract to Trove for Compounding because of this following code present in the GMXDeposit.sol:deposit :
https://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/strategy/gmx/GMXDeposit.sol#L61C3-L66C6

if (self.tokenA.balanceOf(address(this)) > 0) {
self.tokenA.safeTransfer(self.trove, self.tokenA.balanceOf(address(this)));
}
if (self.tokenB.balanceOf(address(this)) > 0) {
self.tokenB.safeTransfer(self.trove, self.tokenB.balanceOf(address(this)));
}

This leads to temporary lockage of User Funds and User will not be able to withdraw it for any immediate needs.

Impact

Temporary Lockage of User Funds

Tools Used

Manual Review

Recommendations

If adding liquidity fails in GMXDeposit.sol::deposit function, then rather than making the cancelling process into another transaction, do it within the same transaction to avoid such vulnerabilities.

Updates

Lead Judging Commences

hans Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
angrymustacheman Submitter
over 1 year ago
hans Auditor
over 1 year ago
hans Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.