Skip to content
$1,000,000 in security audit grants are live now, Apply here →

Security review · October 2024

Hook Updates

for Magna

Guardian's review of Hook Updates for Magna, published October 2024. The report records 8 findings across 2 review rounds, including 1 critical and 7 low.

Published
Review window
October 14 to 24, 2024
Rounds
Main Review, Remediation Review
Language
Solidity
Chains
Ethereum, Base, Optimism, Polygon, Arbitrum, BNB Chain
Sector
Infrastructure
  • 1 Critical
  • 0 High
  • 0 Medium
  • 7 Low
  • 0 Informational

7 resolved · 1 acknowledged

Scope

Findings 8

Main Review

6 findings · October 14 to 15, 2024
  1. C-01 Critical Insufficient postClaimHandler validation Validation Resolved
    Location
    IAirlockBase.sol
    Round
    Main Review

    Description

    IAirlockBase has a postClaimHandlerWhitelist set which includes the whitelisted postClaim handlers added by the trusted role.

    However, when _withdrawToBeneficary is called, it's not checked that the handler is whitelisted. This allows anyone to bypass the postClaim handlers by setting their own contract as the handler and effectively perform direct claims even if they are disallowed.

    Recommendation

    Before claiming, ensure the postClaimHandler is whitelisted. In addition, consider if the extraData passed should also be validated.

  2. L-01 Low withdraw() Can Be Unusable Informational Resolved
    Location
    CalendarV2::L138
    Round
    Main Review

    Description

    withdraw(string calldata _id, uint256 _requestedWithdrawalAmount) calls withdraw(string calldata _id, uint256 _requestedWithdrawalAmount, IPostClaimHandler postClaimHandler, bytes memory extraData) with postClaimHandler hardcoded to address 0.

    If DIRECT_CLAIM_ALLOWED has not been added to postClaimHandlerWhitelist, this will cause a revert inside of _withdrawToBeneficiary.

    Recommendation

    Document to users that they must call the proper withdraw() function when DIRECT_CLAIM_ALLOWED is not allowed.

  3. L-02 Low Typos In Errors Typographical Error Resolved
    Location
    IAirlockBase.sol: 70-86
    Round
    Main Review

    Description

    The errors ClaimHandlerAlreadyWhitlested and ClaimHandlerNotYetWhitlested should be corrected to ClaimHandlerAlreadyWhitelisted and ClaimHandlerNotYetWhitelisted respectively.

    Recommendation

    Correct the typos according to the above.

  4. L-03 Low getPostClaimHandlers return value Return value Resolved
    Location
    IAirlockBase
    Round
    Main Review

    Description

    IAirlockBase.getPostClaimHandlers() will return an array which includes address(0) when direct claim is enabled. Having this value in the array may be unexpected for third parties integrating with the contracts. For example, they may be calling some function on each handler. Then they will call it on address(0) and the tx will revert.

    Recommendation

    Make sure to document this behavior

  5. L-04 Low Incomplete withdraw NatSpec NatSpec Resolved
    Location
    Global
    Round
    Main Review

    Description

    The changed withdraw functions don't include the postClaimHandler and extraData parameters in their NatSpecs.

    Recommendation

    Add these two parameter to the NatSpecs.

  6. L-05 Low Use Stack Variable For postClaimHandlers Gas Optimization Resolved
    Location
    IAirlockBase::L61
    Round
    Main Review

    Description

    postClaimHandlers is a memory array that uses postClaimHandlerWhitelist.length() to set the length of the array. However, on the previous line, the size is already stored as a stack variable. It is cheaper to use that variable than to call postClaimHandlerWhitelist.length().

    Recommendation

    Use arrLength to set the size of the array for postClaimHandlers.

Remediation Review

2 findings · October 24, 2024
  1. L-01 Low Comment On Wrong Withdraw Documentation Resolved
    Location
    IAirlockV2.sol: 45
    Round
    Remediation Review

    Description

    The comment “@dev if direct claim feature is disabled, then this method should not be called” was added for the withdraw function with a postClaimHandler parameter rather than the withdraw function defaulting the handler to address(0).

    Recommendation

    Place the comment for function withdraw(string calldata _id, uint256 _withdrawalAmount) external virtual; instead.

  2. L-02 Low Fee Paid Overwritten Warning Acknowledged
    Location
    MerkleVester.sol
    Round
    Remediation Review

    Description

    Both Calendar and Interval allocations use the same feeAlreadyPayed mapping. If a Calendar and Interval have the same allocation id’s, the fee paid would potentially be set and a claim fee would not be paid for the allocation.

    Recommendation

    Ensure allocation ID’s are unique.

More from Magna

All 9 reports
  1. Staking Updates

    23 findings 23 findings: 3 low, 20 informational
  2. Airdrop Updates

    2 findings 2 findings: 1 low, 1 informational
  3. Direct Transfer

    9 findings 9 findings: 1 medium, 1 low, 7 informational
  4. Merkle Vester

    13 findings 13 findings: 1 medium, 6 low, 6 informational

Put your code through the same review.

This review started with a conversation about scope. Tell us what you are building and we will plan yours with you.

Get a quote