Kakarot precompiles can be called in a staticcall context, allowing writes in view functions #63
Labels
bug
Something isn't working
downgraded by judge
Judge downgraded the risk level of this issue
edited-by-warden
grade-a
primary issue
Highest quality submission among a set of duplicates
QA (Quality Assurance)
Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
🤖_34_group
AI based duplicate group recommendation
sponsor disputed
Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/kkrt-labs/kakarot/blob/7411a5520e8a00be6f5243a50c160e66ad285563/src/kakarot/precompiles/precompiles.cairo#L140
Vulnerability details
Kakarot precompiles (
cairo_precompile
andcairo_message
) allow calling external Starknet functionality from an EVM context.Among the checks that Kakarot makes to secure these Starknet calls, there is no check for the context not to be
read_only
:A check on
read_only
would make sense because when the execution context leaves Kakarot and continues in Starknet contracts, theread_only
information is not propagated to the Cairo execution which can make state-changing operations like ERC-20 token transfers.With the contracts currently planned to be whitelisted,
DualVmToken
andL2KakarotMessaging
, only the latter can be used for this purpose because the events emitted byDualVmToken
revert in a static context. It is therefore possible to send messages to L1 fromview
functions and calls with astaticcall
parent. For this reason, we recommended a Medium severity.Proof of Concept
view
function, whichstaticcall
s a contract whitelisted for Kakarot precompiles which can beL2KakarotMessaging
view
function (solc would make astaticcall
here too)Recommended Mitigation Steps
Within the current scope, only
DualVmToken
andL2KakarotMessaging
are to be whitelisted for cairo calls.DualVmToken
is safe from this because all its "write" operations (approve
,transfer
,transferFrom
) haveemit
statements that will trigger a revert in a read-only context.Similarly, it is recommended that
L2KakarotMessaging
is updated with the emission of an event in itssendMessageToL1
function.In general, all other contracts to be whitelisted for cairo calls should adopt this or similar precautions.
Assessed type
Other
The text was updated successfully, but these errors were encountered: