The bankBalance
function failed to handle errors correctly.
#5
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
M-09
primary issue
Highest quality submission among a set of duplicates
🤖_primary
AI based primary recommendation
🤖_46_group
AI based duplicate group recommendation
satisfactory
satisfies C4 submission criteria; eligible for awards
selected for report
This submission will be included/highlighted in the audit report
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-11-nibiru/blob/8ed91a036f664b421182e183f19f6cef1a4e28ea/x/evm/precompile/funtoken.go#L378
Vulnerability details
Finding description and impact
The
bankBalance
function does not handle errors after decoding the call parameters.As a result,
p.evmKeeper.Bank.GetBalance
may throw a panic, and this erroneous panic cannot be recovered byHandleOutOfGasPanic
, leading to the erroneous panic being propagated further up the program.Proof of Concept
github:https://github.com/code-423n4/2024-11-nibiru/blob/8ed91a036f664b421182e183f19f6cef1a4e28ea/x/evm/precompile/funtoken.go#L378
It can be observed that even if
parseArgsBankBalance
returns an error during decoding, the program will still proceed to callp.evmKeeper.Bank.GetBalance
using incorrect data.This is likely to cause
GetBalance
to throw a panic. This panic is unexpected and, therefore, cannot be caught byHandleOutOfGasPanic
, resulting in the program further throwing an exception.Recommended mitigation steps
The text was updated successfully, but these errors were encountered: