Submitted by RadiantLabs, also found by muellerberndt and zhaojie
The account_contract has a reentrancy check in execute_starknet_call to prevent calls made from the Kakarot EVM to Starknet to re-enter the Kakarot EVM.
The check is implemented by checking that execute_starknet_call calls Kakarots address only with the get_starknet_address getter, which is indeed harmless:
However, this check leaves another possibility open, that is that the account_contract could call itself or another account_contract with a signed transaction to re-enter the Kakarot EVM, which is extremely vulnerable to reentrancy because of its extensive use of cached data.
While an exploit via this path can have critical impact on the integrity of the EVM, its likelihood is extremely low because execute_starknet_call is accessible only via whitelisted contracts.
Because Kakarot stores the effects of the execution at the very end of it via the Starknet.commit, it openly does not follow the check-effect-interaction pattern, so the integrity of the EVM is at risk of reentrancy via submissions of signed transactions within the call cairo precompile.
Consider removing the reentrancy check in account_contract, and adding a reentrancy guard on the Kakarot.eth_call function.
ClementWalter (Kakarot) confirmed and commented:
obatirou (Kakarot) commented:
LSDan (judge) commented:
ahmedaghadi (warden) commented:
LSDan (judge) commented:
Kakarot mitigated:
Status: Mitigation confirmed.
