Closed code423n4 closed 1 year ago
https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/vaults/AutoPxGlp.sol#L240-L246 https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexGmx.sol#L600
AutoPxGlp.compound() might revert forever if gmxBaseReward is not whitelisted in gmxVault.
AutoPxGlp.compound()
gmxBaseReward
gmxVault
As a result, most functions like withdraw() and redeem() using the compound() function inside will revert.
withdraw()
redeem()
compound()
AutoPxGlp.compound() deposits the earned gmxBaseReward into the PirexGmx contract and mints pxGlp.
PirexGmx
pxGlp
if (gmxBaseRewardAmountIn != 0) { // Deposit received rewards for pxGLP (, pxGlpAmountOut, ) = PirexGmx(platform).depositGlp( address(gmxBaseReward), gmxBaseRewardAmountIn, minUsdg, minGlp, address(this) ); }
And PirexGmx.depositGlp() accepts the whitelisted tokens only.
PirexGmx.depositGlp()
if (token == address(0)) revert ZeroAddress(); if (!gmxVault.whitelistedTokens(token)) revert InvalidToken(token);
Also, while checking the gmxVault contract, there is no guarantee gmxBaseReward is whitelisted.
So if gmxBaseReward is not a whitelisted token in the gmxVault, compound() will revert.
Manual Review
We should check if the gmxBaseReward is whitelisted or not in compound().
And should consider swapping the gmxBaseReward to the whitelisted token using a swap router.
Considering that gmxBaseReward is GMX protocol base reward, the chances it is not whitelisted are very low
GMX protocol base reward
Duplicate of https://github.com/code-423n4/2022-11-redactedcartel-findings/issues/347
Lines of code
https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/vaults/AutoPxGlp.sol#L240-L246 https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexGmx.sol#L600
Vulnerability details
Impact
AutoPxGlp.compound()
might revert forever ifgmxBaseReward
is not whitelisted ingmxVault
.As a result, most functions like
withdraw()
andredeem()
using thecompound()
function inside will revert.Proof of Concept
AutoPxGlp.compound()
deposits the earnedgmxBaseReward
into thePirexGmx
contract and mintspxGlp
.And
PirexGmx.depositGlp()
accepts the whitelisted tokens only.Also, while checking the gmxVault contract, there is no guarantee
gmxBaseReward
is whitelisted.So if
gmxBaseReward
is not a whitelisted token in thegmxVault
,compound()
will revert.Tools Used
Manual Review
Recommended Mitigation Steps
We should check if the
gmxBaseReward
is whitelisted or not incompound()
.And should consider swapping the
gmxBaseReward
to the whitelisted token using a swap router.