Closed code423n4 closed 1 year ago
Since baseRewards is calculated by using pre and post balance, attacker can simply trigger it by transferring gmxBaseReward to the contract, passing the check if (baseRewards != 0).
How would you this considering the fact that the attacker is not suppose to be able to execute code between the pre and post balance check ?
The scenario for how to get to a point where gmxBaseRewards == 0
, glpBaseRewards == 0
but baseRewards > 0
is not convincing.
The scenario for how to get to a point where gmxBaseRewards == 0
, glpBaseRewards == 0
but baseRewards > 0
is not convincing.
Picodes marked the issue as unsatisfactory: Insufficient proof
Lines of code
https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexGmx.sol#L802-L804
Vulnerability details
Impact
When functions
harvest()
orclaim()
of PirexRewards are called, they will claim rewards by callingPirexGmx.claimRewards()
function. If there is any case that esGmx reward is existed but not base rewards or vice versa, the value returned from_calculateRewards()
is 0 and it leads to division by zero and revert.For example,
Since
baseRewards
is calculated by using pre and post balance, attacker can simply trigger it by transferringgmxBaseReward
to the contract, passing the checkif (baseRewards != 0)
.Proof of Concept
Function
harvest()
callsclaimRewards()
. https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexRewards.sol#L338-L348In function
claimRewards()
, rewards amount is calculated by substracting post balance with pre balance https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexGmx.sol#L785-L790Function
_calculateRewards()
can return zero when there is lacking rewards in distributor. https://github.com/code-423n4/2022-11-redactedcartel/blob/03b71a8d395c02324cb9fdaf92401357da5b19d1/src/PirexGmx.sol#L250-L254Tools Used
Manual Review
Recommended Mitigation Steps
Consider adding zero check before doing the division.