sherlock-audit / 2023-07-perennial-judging

2 stars 1 forks source link

marcoyaax - Possible reentrancy with claimReward() function #174

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

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.

sherlock-admin commented 1 year ago

2 comment(s) were left on this issue during the judging contest.

141345 commented:

d

panprog commented:

invalid because owner is trusted and reward tokens approved are also trusted