Liquid Staking

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

contracts/core/base/Strategy.sol

Let’s analyze the potential vulnerabilities and risks associated with your Solidity code based on known patterns, best practices, and common pitfalls. Here's what I found:


1. Upgradeability Risks (UUPS pattern)

  • Vulnerability:
    Using UUPSUpgradeable for upgradability requires careful control over the _authorizeUpgrade function. If it’s improperly controlled, it could allow unauthorized upgrades.

  • Review:
    The _authorizeUpgrade function is protected by onlyOwner. While this is good, ensure:

    • There are no ways for ownership to be transferred to unintended addresses.

    • Proper ownership management should be implemented (e.g., transferOwnership only to trusted addresses).
      Risk: If OwnableUpgradeable is compromised, so is the upgrade mechanism.


2. Initialization Vector Risks

  • Vulnerability:
    There’s a chance that the __Strategy_init function could be called more than once if the initializer modifier is bypassed.

  • Mitigation:

    • Make sure all upgradeable contracts (via Initializable) are initialized correctly by using onlyInitializing. Also, check that __Strategy_init is invoked only once.

    • Ensure proxy contracts using this base contract properly call this initializer when deploying. A missed initializer call can lead to ownership bugs or locked functionality.


3. ERC20 Token Interaction Risks

  • Vulnerability:

    • Reentrancy: If the token supports callbacks (e.g., ERC777 tokens), calling functions like transfer or transferFrom may introduce reentrancy risks.

    • Approval Risks: If approval is given to the wrong contracts or misused, tokens may be stolen.

  • Mitigation:

    • Consider using ReentrancyGuard to mitigate reentrancy risks, especially if more logic (e.g., token transfers) is introduced in inherited contracts.

    • Use OpenZeppelin’s safeTransfer or safeTransferFrom to ensure token transfers succeed.


4. Lack of Input Validation in Initializer

  • Vulnerability:

    • There is no validation for _token and _stakingPool addresses in the initializer. If a zero address or malicious contract is passed, it could result in broken logic or attack vectors.

  • Mitigation:

    • Add checks in __Strategy_init:

      require(_token != address(0), "Invalid token address");
      require(_stakingPool != address(0), "Invalid staking pool address");

5. Use of onlyOwner Modifier for Critical Actions

  • Vulnerability:
    Using onlyOwner for critical functions (like upgrades) can be risky if ownership is transferred accidentally or if there’s an exploit in the Ownable contract.

  • Mitigation:

    • If possible, consider multisig wallets or time-locked upgrades to reduce the risks from single points of control.


6. Insufficient Modifier on getTotalDeposits and Related Functions

  • Observation:
    Functions like getTotalDeposits, getMaxDeposits, and getMinDeposits are public. This may not pose a direct vulnerability, but they could:

    • Reveal sensitive information if not intended.

    • Be spammed to waste gas and computation time.

  • Mitigation:
    If these are meant to be internal logic helpers, you can restrict them:

    function getTotalDeposits() internal view virtual returns (uint256);

7. No Event Logging for Critical Actions

  • Observation:
    The code lacks event logging. For example, if upgrades or state-changing actions occur, there are no events to track them. This makes troubleshooting and transparency difficult.

  • Mitigation:

    • Emit events for upgrades and other significant actions, e.g.:

      event Upgraded(address indexed newImplementation);
      function _authorizeUpgrade(address newImplementation) internal override onlyOwner {
      emit Upgraded(newImplementation);
      }

8. Potential Centralization Risk with onlyStakingPool Modifier

  • Vulnerability:
    The onlyStakingPool modifier allows only the stakingPool address to call certain functions. If stakingPool is compromised, it could manipulate the strategy’s behavior.

  • Mitigation:

    • Carefully vet the staking pool logic.

    • Consider adding role-based access control instead of hard-coding trust in one address.


9. Handling of Overflow or Underflow (though Solidity 0.8+ has checks)

  • Observation:
    Solidity 0.8+ provides built-in overflow/underflow protection. However, if inherited contracts manipulate balances (like deposits or withdrawals), double-check for overflows in logic-heavy calculations.


Summary

  • Critical Risks:

    1. Improper ownership management can compromise upgrades.

    2. Missing input validation for the initializer parameters.

    3. Token interaction risks (reentrancy and incorrect transfers).

  • Recommendations:

    1. Add input validation to the initializer.

    2. Use safeTransfer/safeTransferFrom for token interactions.

    3. Emit events for critical actions.

    4. Consider multisig control for upgrades to reduce risks from onlyOwner.

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.