Submitted by cmichel
LockedBalance.sol#L56
The LockedBalance contract takes 256-bit amount values but performs bit math on them as if they were 96 bit values.
Bits could spill over to a different locked balance in the else part (lockedBalance stores two 128-bit locked balances in one 256-bit storage field):
It could then increase the other, unrelated locked balances amount leading to stealing funds from the protocol.
All callers of this function currently seem to ensure that totalAmount is indeed less than 96 bits but the LockedBalance library should be self-contained and not depend on the calling side to perform all checks.
If the code is ever extended and more calls to these functions are performed, itll likely cause issues.
Make sure that there are only 96/32 bits set in totalAmount and expiration by dropping them to their respective types.
NickCuso (Foundation) acknowledged and commented:
