Wrong gas price calculation in eth_send_raw_unsigned_tx
could lead to suboptimal transaction pricing
#133
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
edited-by-warden
primary issue
Highest quality submission among a set of duplicates
🤖_47_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/kkrt-labs/kakarot/blob/7411a5520e8a00be6f5243a50c160e66ad285563/src/kakarot/eth_rpc.cairo#L304-L307
Vulnerability details
Proof of Concept
eth_rpc.cairo::eth_send_raw_unsigned_tx
underprices transactions, which could lead to delayed or failed transactions in congested network conditions.Take a look at this part of the code:
https://github.com/kkrt-labs/kakarot/blob/7411a5520e8a00be6f5243a50c160e66ad285563/src/kakarot/eth_rpc.cairo#L304-L307
The problem is in the calculation of
priority_fee_per_gas
. The logic attempts to choose betweentx.max_priority_fee_per_gas
andpossible_priority_fee
, but it does so incorrectly.The issue is that
priority_fee_is_max_priority_fee
is set to 1 whenpossible_priority_fee
is greater than or equal totx.max_priority_fee_per_gas
, which is the opposite of what we actually want. This means that when thepossible_priority_fee
is larger, the function will choosetx.max_priority_fee_per_gas
instead of the smaller value.As a result, in some cases,
the priority_fee_per_gas
could be set higher/lower than intended leading to users paying more/less in gas fees than necessary.In most cases, transactions may be underpriced relative to what the user is willing to pay. In congested network conditions, transactions may end up being delayed or failing to be processed cos they're not utilizing the full gas price the user was willing to pay.
Short Note:
Recommended Mitigation Steps
The calculation of
priority_fee_is_max_priority_fee
should be inverted.Assessed type
Error
The text was updated successfully, but these errors were encountered: