Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: medium
Invalid

contracts/core/lstRewardsSplitter/LSTRewardsSplitterController.sol

1. Reentrancy Attacks

While the contract doesn't seem to perform any state updates before calling external contracts, it's always wise to use the checks-effects-interactions pattern. Specifically, you should be cautious in functions that involve transferring tokens or calling external contracts (like withdraw and performUpkeep).

2. Gas Limit Issues in Loops

The checkUpkeep and performUpkeep functions loop through the accounts array. If this array grows large, it could lead to a gas limit exceedance. Consider implementing a mechanism to limit the number of splitters that can be processed in a single transaction.

3. Error Handling for External Calls

The contract relies on external calls to splitters[accounts[i]].checkUpkeep("") and splitters[accounts[i]].performUpkeep(""). If these functions revert, it can cause your contract to revert without providing useful feedback. It's generally a good idea to handle potential failures from external calls gracefully, for instance, by using try/catch blocks if you're using Solidity 0.6.0 or later.

4. Potential Integer Overflow/Underflow

Although you're using Solidity 0.8.15, which has built-in overflow/underflow checks, it's still important to ensure any arithmetic operations are safe, especially if you decide to manipulate values based on user input.

5. Inefficient Array Removal

The removeSplitter function removes an element from the accounts array by replacing it with the last element and popping it. This can lead to a situation where the order of the accounts is not preserved, which may be acceptable or not based on your requirements. If the order matters, consider using a more sophisticated method or maintaining an auxiliary structure to track indices.

6. Lack of Access Control for Critical Functions

Although the addSplitter and removeSplitter functions are protected by onlyOwner, consider if other sensitive functions (like setRewardThreshold) also require stricter access control or additional checks to prevent abuse.

7. Approval for Max Tokens

When you use safeApprove with type(uint256).max, it’s generally safe if you’re aware of the risks associated with it. In cases where the approval might be misused, you should consider using the increaseAllowance or decreaseAllowance methods instead, which mitigate the risk of the approval race condition.

8. Lack of Events for Key Actions

Consider emitting events for critical actions like adding or removing splitters, withdrawals, or setting the reward threshold. This enhances transparency and makes it easier to track contract activity on-chain.

9. No Validation of Input Data

In addSplitter, the _account address is not validated to ensure it is not zero or a contract that does not implement the required interface. Similarly, the _fees parameter should also be validated, if applicable, to prevent misuse.

10. Interface Compatibility

Ensure that the interfaces IERC677 and ILSTRewardsSplitter are correctly defined and match the expected function signatures. Mismatches can lead to unexpected behavior or failures during execution.

Recommendations for Improvement

  • Implement reentrancy guards (e.g., using nonReentrant modifier from OpenZeppelin).

  • Consider optimizing the accounts management and potentially using a different data structure for better performance.

  • Emit events for actions such as adding/removing splitters, withdrawing, etc., to facilitate easier tracking and auditing.

  • Enhance error handling for external contract calls.

By addressing these points, you can enhance the security and robustness of the contract.

Updates

Lead Judging Commences

inallhonesty Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.