LibStrings.toString(int256 value)
cannot handle value = type(int256).min
or value = 0
.
LibStrings.toString(int256 value)
does not handle all int256
values correctly.
The incorrectly handled values are type(int256).min
and 0
:
toString(int256 value)
method handles negative int256
values by first converting them to positive, then casting them to uint256
, and passing them to LibStrings.toString(uint256 value)
. However, if value = type(int256).min
, the negation -value
will cause an overflow because -type(int256).min
exceeds type(int256).max
, due to the asymmetry of int256
. Consequently the call to toString(int256 value)
will revert.
value = 0
is catched by the else
branch and thus will generate incorrectly formatted negative strings like -0
.
See the example POC for the value = type(int256).min
case below (Run it using foundry):
As described above, LibStrings.toString(int256 value)
does not handle correctly value = type(int256).min
or value = 0
, which affects the functionality of MetadataFacet.sol
. Nevertheless, since both are edge cases, it should be considered a low severity issue.
Manual Review.
Consider applying the fix below.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.