stake.link

stake.link
DeFiHardhatBridge
27,500 USDC
View results
Submission Details
Severity: high
Invalid

Reentrancy Attack Risk In `distributeRewards()` Function

Summary

Possible reentrancy attack in distributeRewards() function

Vulnerability Details

In the distributeRewards() function of the smart contract, a reentrancy attack could occur if the ISDLPoolPrimary(sdlPool).withdrawRewards(tokens); line calls an external contract that has a fallback function or a callback function.

Impact

If this external contract is malicious or poorly designed, it could call back into the distributeRewards() function before the state of the distributeRewards() function has been fully updated. This could lead to unexpected behavior or potential loss of funds.

Recommendations

Perform all external calls at the end of the function, after the state has been fully updated. This ensures that even if the external call causes the function to be called again, it won't affect the current execution of the function.

function distributeRewards() public {
// Update state here...
// Make external calls at the end
ISDLPoolPrimary(sdlPool).withdrawRewards(tokens);
}
Updates

Lead Judging Commences

0kage 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.