Closed code423n4 closed 2 years ago
As per solidity docs the default value for uint is 0: https://docs.soliditylang.org/en/v0.8.13/control-structures.html#scoping-and-declarations
Dispute accepted, I'm yet to see an incident of an uninitialised variable not being zero.
Lines of code
https://github.com/RollaProject/quant-protocol/blob/main/contracts/libraries/QuantMath.sol#L73
Vulnerability details
Impact
tailing
is uninitialized inQuantMath.sol/toScaledUint()
. In the case here, solc-bin(0.8.13) implicitly sets uninitialized tailing stack value to 0, but this feature is undocumented and not guaranteed in solc, thus it would be best to do an explicit initialization here.Proof of Concept
If
_roundDown
isTrue
,tailing
will be uninitializedhttps://github.com/RollaProject/quant-protocol/blob/main/contracts/libraries/QuantMath.sol#L73
Tools Used
Manual code review.
Recommended Mitigation Steps
Initialize
tailing
to 0 or removetailing
like the following code