sherlock-audit / 2024-03-arrakis-judging

2 stars 2 forks source link

abi.encodePacked may break with some initManagement signatures #99

Closed sherlock-admin3 closed 4 months ago

sherlock-admin3 commented 4 months ago

abi.encodePacked may break with some initManagement signatures

Low/Info issue submitted by cergyk

Summary

The current implementation of the initManagement function uses abi.encodePacked for encoding the SetupParams struct. This approach may break if the struct includes dynamic length variables such as bytes. Adding such variables would change the struct's encoding to dynamic, causing the function to fail.

Vulnerability Detail

The initManagement function in ArrakisStandardManager uses the SetupParams struct as an argument: ArrakisStandardManager.sol#L447, SManager.sol#L17-L25.

Currently, abi.encodePacked works because the struct only contains static size parameters: ArrakisMetaVaultFactory.sol#L459-L461.

However, if a dynamic length variable such as bytes is added to the struct, the struct itself becomes dynamic. This means that the first word of its encoding would be its offset, which would break the function's logic.

Impact

If dynamic length variables are added to the SetupParams struct, the use of abi.encodePacked will lead to incorrect encoding. This will result in failures when calling initManagement.

Code Snippet

Tool used

Manual Review

Recommendation

Mitigation is not trivial and this is not a concern currently. However, please be aware that it may break if a dynamic variable is added to the struct in the future so avoid adding dynamic parameters to the struct.