Liquid Staking

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

test/core/priorityPool/distribution-oracle.test.ts

1. Authorization & Access Control Issues

  • Setting Authorized Senders:

    await opContract.setAuthorizedSenders([accounts[0]])
    • Risk: If unauthorized addresses can access or manipulate this function, they could gain control over oracle updates.

    • Mitigation: Ensure that only the contract owner or a specific role can set authorized senders.


2. Oracle Manipulation Risk

  • OracleRequest & Fulfillment Flow:

    await opContract.fulfillOracleRequest2(...)
    • Risk: If malicious actors gain control over the oracle input (i.e., fulfillOracleRequest2), they can provide manipulated or incorrect data. This could impact payouts or state updates.

    • Mitigation:

      • Use off-chain data sources with multiple validations (decentralized oracles).

      • Ensure the sender of fulfillOracleRequest2 is verified (like Chainlink node verification).


3. Reentrancy Attack Risk

  • Pause and Update Logic:
    Functions such as pauseForUpdate() and requestUpdate() interact with oracle and contract state:

    await oracle.pauseForUpdate()
    await oracle.requestUpdate()
    • Risk: If external calls (like fulfillOracleRequest2) trigger state changes and interact with other contracts, it could allow reentrancy.

    • Mitigation:

      • Use the Checks-Effects-Interactions pattern.

      • Consider using OpenZeppelin’s ReentrancyGuard.


4. Insufficient Block Confirmation Logic

  • Block Confirmations in requestUpdate:

    await expect(oracle.requestUpdate()).to.be.revertedWithCustomError(
    oracle,
    'InsufficientBlockConfirmations()'
    )
    • Risk: There may be an assumption about the block confirmation window that could be manipulated by miners (e.g., time-bandit attacks or block reorgs).

    • Mitigation: Consider using time-based checks (like block.timestamp) along with block numbers for stricter validation.


5. Lack of Input Validation

  • Encoding and Data Handling:

    ethers.AbiCoder.defaultAbiCoder().encode([...])
    • Risk: If untrusted input gets encoded without proper validation (e.g., bytes32 for IPFS or Merkle values), it could introduce vulnerabilities (e.g., invalid data or storage attacks).

    • Mitigation: Add input validation checks before encoding, especially when using user-provided data.


6. Token Transfer Safety

  • WithdrawLink Functionality:

    await oracle.withdrawLink(toEther(20))
    • Risk: If there is no safeguard around who can call withdrawLink, attackers could drain tokens from the contract.

    • Mitigation:

      • Limit access to token withdrawal to specific roles (e.g., only the owner).

      • Consider adding time locks or multi-sig approval processes for withdrawals.


7. Unchecked External Call Return Values

  • Fulfillment Calls and External Contracts:
    Calls to fulfillOracleRequest2 and token transfer operations need to handle potential failures:

    await token.transfer(adrs.oracle, toEther(100))
    • Risk: If these external calls silently fail, the contract logic may behave incorrectly.

    • Mitigation:

      • Use try-catch blocks or validate return values from external contract calls.

      • Consider OpenZeppelin’s SafeERC20 wrapper for token transfers.


8. Manual Verification Logic Loophole

  • Manual Verification Switch:

    await oracle.toggleManualVerification()
    await expect(oracle.executeManualVerification()).to.be.revertedWithCustomError(
    oracle,
    'NoVerificationPending()'
    )
    • Risk: Improper handling of manual verification state could leave the contract stuck if verification isn’t completed.

    • Mitigation: Ensure that verification steps cannot deadlock the contract’s ability to process further requests.


Summary & Recommendations

While the code appears logically correct, addressing the following areas can help avoid vulnerabilities:

  1. Implement role-based access control for sensitive functions (like withdrawals and sender authorization).

  2. Validate inputs and handle external call failures gracefully.

  3. Mitigate reentrancy risks by following secure design patterns.

  4. Check for block manipulation risks using both block numbers and timestamps.

Making these changes will strengthen the overall security of your smart contract system.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

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