Attackathon _ Fuel Network 32412 - [Smart Contract - Insight] the IFP divide functions does not have
Submitted on Thu Jun 20 2024 14:54:21 GMT-0400 (Atlantic Standard Time) by @zeroK for Attackathon | Fuel Network
Report ID: #32412
Report type: Smart Contract
Report severity: Insight
Target: https://github.com/FuelLabs/sway-libs/tree/0f47d33d6e5da25f782fc117d4be15b7b12d291b
Impacts:
Unbounded gas consumption
Block stuffing
Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
the function divide
in the ifp libs are used to divide two number, however this function mentioned that the function will panic when divisor is zero rather than revert with helpful error messgae, this can cause trouble for users interfaces in case of debugging. an assert
is implemented in UFP libs which revert in this case rather than panic the whole fuelVM.
Vulnerability Details
the divide
in IFP libs are implemented as below:
as shown above the call will panic if the divisor is zero and no check implemented to revert with reason rather than panic similar to ufp libs:
Impact Details
the divide function panics when the divisor is zero rather than revert with helpful error message.
References
its recommended to avoid panics in fuelVM by using assert, implement the ifp libs similar to ufp libs.
Proof of concept
Proof of Concept
Last updated