The withdrawal mechanism in KernelStrategy is similar, but it distributes the base asset to the user (defined as the receiver parameter) instead of withdrawing from another vault.
If the base asset is an ERC20 token equipped with a callback function, the user could designate a contract as the receiver. This contract can then invoke the processAccounting function, which updates the totalAssets variable in the Max Vault. Since the buffer strategy burns shares only after the transfer, the shares in the Max Vault have not yet been burned.
This allows the totalAssets variable to revert to its pre-withdrawal value. As a result, the user’s shares in the Max Vault are subsequently burned, leading to an inflation in share value (the totalAssets remains constant while the number of shares decreases).
Note: This issue has been reported as medium because the currently used assets do not pose such threat, although the team plans to dynamically expand their offer.
Impact
MEDIUM – This attack results in the theft of assets alongside an inflated share value.
Recommendation
To mitigate this issue, it is essential to implement the Checks-Effects-Interactions pattern. This ensures that the transfer of tokens to the user occurs only after the shares have been fully burned.
Additionally, the processAccounting function should incorporate a nonReentrant modifier to prevent potential reentrancy attacks.