Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[L-01] Potential Reentrancy Vulnerability in Reward Distribution #290

Open
softstackio opened this issue Jan 13, 2025 · 0 comments · May be fixed by #297
Open

[L-01] Potential Reentrancy Vulnerability in Reward Distribution #290

softstackio opened this issue Jan 13, 2025 · 0 comments · May be fixed by #297
Assignees

Comments

@softstackio
Copy link

Likelihood: Low

Description
The _distributeRewards function in the BlockRewardHbbft contract contains a potential reentrancy vulnerability. Although the contract uses OpenZeppelin's ReentrancyGuard, the function makes an external call to TransferUtils.transferNative before updating the contract's state. This violates the checks-effects-interactions pattern.

TransferUtils.transferNative(governancePotAddress, shares.governancePotAmount);
// State changes follow external call
distributedAmount += poolReward;

While the ReentrancyGuard provides some protection, it's still best practice to follow the checks-effects-interactions pattern to minimize risk.

Recommendation:

  1. Implement the checks-effects-interactions pattern by updating the contract's state before making external calls.
  2. Move the Transfer Utils.transferNative call to the end of the function after all state changes.
  3. Consider using OpenZeppelin's Address.sendValue for ETH transfers, which includes built-in reentrancy protection.
@axel-muller axel-muller self-assigned this Jan 23, 2025
@axel-muller axel-muller linked a pull request Jan 28, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants