In the Vault the ERC20 _transfer ,_mint and _burn methods are overridden to use the TwabController functionality, and these call to the TwabController unsafely cast shares from uint256 to uint96. As a result, if a user tries to transfer/mint/burn more than uint96 shares they will lose some shares during the action due to silent overflows.
Mitigation
The updated implementation uses the OZ SafeCast library to safely cast the input uint256 shares value to uint96 for calls to the relevant TwabController methods. There is now no risk of a silent overflow so the issue is resolved.
Lines of code
Vulnerability details
Comments
In the Vault the ERC20
_transfer
,_mint
and_burn
methods are overridden to use the TwabController functionality, and these call to the TwabController unsafely cast shares fromuint256
touint96
. As a result, if a user tries to transfer/mint/burn more thanuint96
shares they will lose some shares during the action due to silent overflows.Mitigation
The updated implementation uses the OZ SafeCast library to safely cast the input
uint256
shares value touint96
for calls to the relevant TwabController methods. There is now no risk of a silent overflow so the issue is resolved.Conclusion
LGTM