Attackathon _ Fuel Network 33450 - [Blockchain_DLT - Insight] fuel_gas_price_algorithm AlgorithmV ma
Submitted on Sat Jul 20 2024 17:22:45 GMT-0400 (Atlantic Standard Time) by @Crab for Attackathon | Fuel Network
Report ID: #33450
Report type: Blockchain/DLT
Report severity: Insight
Target: https://github.com/FuelLabs/fuel-core/tree/v0.31.0
Impacts:
Causing network processing nodes to process transactions from the mempool beyond set parameters (e.g. prevents processing transactions from the mempool)
Description
Brief/Intro
The fuel_gas_price_algorithm::AlgorithmV1
calculate
function may panic if it is not initialized correctly. This would result in the halting of nodes on mainnet and would stop the network from working correctly.
Vulnerability Details
The AlgorithmV1
is currently unused but would be used to determine the price of the current gas price on Fuel. It is featuring a PID controller (without the I component though) that takes in the block profit target and adjust the P (proportional) and D (derivative) parameters in order to tend to reach it. There is a bug though that gets triggered when the abs
function is called. It triggers a panic with the message "attempt to negate with overflow". This will panic whenever p + d == i64::MIN
because -i64::MIN
is undefined on the range of the integers.
This has been found with fuzzing, with the following input:
And here is the fuzzing target:
You can adjust the target so that it will reject invalid p and d factors and won't trigger the bug anymore:
The code had to be instrumented to be able to import the AlgorithmV1
and the fields have been made public to build this harness.
You can look at the bug more closely with the following reduced code
Impact Details
The AlgorithmV1
does not seem to be used right now, but if it is and that the parameters are not checked correctly, it will panic on mainnet and halt all of the nodes of the network since they should agree on the same parameters.
References
Proof of concept
Proof of Concept
Last updated