When the sender tries to call claimReward() function, it can trigger a reentrancy attack.
Vulnerability Detail
When the sender calls claimReward() function, it fetches the memory locally and checks if the sender has a valid reward. And this reward is sent to the sender. Also, since the transmission of the reward occurs before it is written to memory, this can be an opportunity for reentrancy attacks.
Impact
Loss of funds. This may result in loss of rewards in the contract.
marcoyaax
medium
Possible reentrancy with claimReward() function
Summary
When the sender tries to call claimReward() function, it can trigger a reentrancy attack.
Vulnerability Detail
When the sender calls claimReward() function, it fetches the memory locally and checks if the sender has a valid reward. And this reward is sent to the sender. Also, since the transmission of the reward occurs before it is written to memory, this can be an opportunity for reentrancy attacks.
Impact
Loss of funds. This may result in loss of rewards in the contract.
Code Snippet
https://github.com/sherlock-audit/2023-07-perennial/blob/main/perennial-v2/packages/perennial/contracts/Market.sol#L154
Tool used
Manual Review
Recommendation
Update the memory before transfer reward to the sender.