Attackathon _ Fuel Network 32786 - [Smart Contract - Low] incorrect set of i bits to which it should
Submitted on Tue Jul 02 2024 13:13:27 GMT-0400 (Atlantic Standard Time) by @zeroK for Attackathon | Fuel Network
Report ID: #32786
Report type: Smart Contract
Report severity: Low
Target: https://github.com/FuelLabs/sway-libs/tree/0f47d33d6e5da25f782fc117d4be15b7b12d291b
Impacts:
Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
the i256 is used to create/refer to signed value for u256 while sway can not handle negative value, however the bits function return incorrect bit value which is 128 bits, this is not true as i128 return 128 bits and i256 should return 256 bits same as shown in the sway-core/primitives.sw
std.
Vulnerability Details
the bits sets to 128 for i256 as shown below:
but this is not true as i128 return 128 bits too:
while in the primitives its clear that u256 should return 256 bit:
Impact Details
the i256.sw bit function return incorrect bit number.
References
return 256 bit in the bit function for i256.sw lib
Proof of concept
Proof of Concept
run the test right below the bit function in i256.sw:
Last updated