Steadefi

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

GMXVault : Lack of approval set for `exchangeRouter` and `GMXVault` contract`

Summary

No approval is set for exchangeRouter and GMXVault contracts to use tokenA, tokenB and lpToken.`

Vulnerability Details

Both exchangeRouter and GMXVault contracts are interacting with tokenA, tokenB and lpToken to deposit, withdraw and other transactions with the GMX v2.

Lets see for exchangeRouter contract in GMXWorker.sol#L23-L44

self.exchangeRouter.sendWnt{ value: alp.executionFee }(
self.depositVault,
alp.executionFee
);
// Send tokens
self.exchangeRouter.sendTokens(
address(self.tokenA),
self.depositVault,
alp.tokenAAmt
);
self.exchangeRouter.sendTokens(
address(self.tokenB),
self.depositVault,
alp.tokenBAmt
);

Since the allowance is not set for exchangeRouter, the above transaction will not work.

Further when we look at the comments in vault contract, it says that set approval for vault, but the approval is set for router.

https://github.com/Cyfrin/2023-10-SteadeFi/blob/0f909e2f0917cb9ad02986f631d622376510abec/contracts/strategy/gmx/GMXVault.sol#L117-L120

// Set token approvals for this vault ------------------------->> refer
_store.tokenA.approve(address(_store.router), type(uint256).max); -------->> these approvals are set to router.
_store.tokenB.approve(address(_store.router), type(uint256).max);
_store.lpToken.approve(address(_store.router), type(uint256).max);

Impact

Transaction with GMX v2 contract will not work properly.

Tools Used

Manual review

Recommendations

We suggest to provide necessary allowance to exchangeRouter vault contracts to use the tokens for transaction.

Updates

Lead Judging Commences

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.