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
Scope
Findings 8
Main Review
6 findings · October 14 to 15, 2024-
C-01 Critical Insufficient postClaimHandler validation Validation Resolved
Description
IAirlockBase has a
postClaimHandlerWhitelistset 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
postClaimHandleris whitelisted. In addition, consider if theextraDatapassed should also be validated. -
L-01 Low
withdraw()Can Be Unusable Informational ResolvedDescription
withdraw(string calldata _id, uint256 _requestedWithdrawalAmount)callswithdraw(string calldata _id, uint256 _requestedWithdrawalAmount, IPostClaimHandler postClaimHandler, bytes memory extraData)withpostClaimHandlerhardcoded to address 0.If
DIRECT_CLAIM_ALLOWEDhas not been added topostClaimHandlerWhitelist, this will cause a revert inside of_withdrawToBeneficiary.Recommendation
Document to users that they must call the proper
withdraw()function whenDIRECT_CLAIM_ALLOWEDis not allowed. -
L-02 Low Typos In Errors Typographical Error Resolved
Description
The errors
ClaimHandlerAlreadyWhitlestedandClaimHandlerNotYetWhitlestedshould be corrected toClaimHandlerAlreadyWhitelistedandClaimHandlerNotYetWhitelistedrespectively.Recommendation
Correct the typos according to the above.
-
L-03 Low getPostClaimHandlers return value Return value Resolved
Description
IAirlockBase.getPostClaimHandlers()will return an array which includesaddress(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 onaddress(0)and the tx will revert.Recommendation
Make sure to document this behavior
-
L-04 Low Incomplete withdraw NatSpec NatSpec Resolved
Description
The changed
withdrawfunctions don't include thepostClaimHandlerandextraDataparameters in their NatSpecs.Recommendation
Add these two parameter to the NatSpecs.
-
L-05 Low Use Stack Variable For
postClaimHandlersGas Optimization ResolvedDescription
postClaimHandlersis a memory array that usespostClaimHandlerWhitelist.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 callpostClaimHandlerWhitelist.length().Recommendation
Use
arrLengthto set the size of the array forpostClaimHandlers.
Remediation Review
2 findings · October 24, 2024-
L-01 Low Comment On Wrong Withdraw Documentation Resolved
Description
The comment “@dev if direct claim feature is disabled, then this method should not be called” was added for the
withdrawfunction with apostClaimHandlerparameter rather than thewithdrawfunction defaulting the handler toaddress(0).Recommendation
Place the comment for
function withdraw(string calldata _id, uint256 _withdrawalAmount) external virtual;instead. -
L-02 Low Fee Paid Overwritten Warning Acknowledged
Description
Both Calendar and Interval allocations use the same
feeAlreadyPayedmapping. 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.
No findings match.
More from Magna
All 9 reportsPut 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.