Non-deterministic gas consumption due to shared StateDB pointer in bank keeper affecting consensus #57
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
H-02
primary issue
Highest quality submission among a set of duplicates
🤖_17_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
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-11-nibiru/blob/84054a4f00fdfefaa8e5849c53eb66851a762319/x/evm/keeper/bank_extension.go#L84-L86
Vulnerability details
Finding description and impact
An issue exists in Nibiru's implementation of the bank keeper and its interaction with the EVM's StateDB. The
NibiruBankKeeper
maintains a pointer field toStateDB
that gets updated during read-only EVM operations (likeeth_estimateGas
), which then affects the gas computation of subsequent bank transactions.The issue arises because the
StateDB
pointer inNibiruBankKeeper
is modified during read-only operations, and the presence or absence of this pointer affects program flow in bank operations through nil checks:This can lead to consensus failures as different nodes may compute different gas amounts for the same transaction (depending on if they previously executed a read only query via RPC), which should never happen.
Proof of Concept
The vulnerability can be demonstrated through the following sequence:
The key problematic code is in bank_extension.go:
Recommended mitigation steps
There are several ways to fix this issue:
The solution must ensure:
The text was updated successfully, but these errors were encountered: