Return value of ERC-20 operations is not checked #51
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
primary issue
Highest quality submission among a set of duplicates
🤖_primary
AI based primary recommendation
🤖_23_group
AI based duplicate group recommendation
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
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/kkrt-labs/kakarot/blob/7411a5520e8a00be6f5243a50c160e66ad285563/solidity_contracts/src/CairoPrecompiles/DualVmToken.sol#L269
https://github.com/kkrt-labs/kakarot/blob/7411a5520e8a00be6f5243a50c160e66ad285563/solidity_contracts/src/CairoPrecompiles/DualVmToken.sol#L353
https://github.com/kkrt-labs/kakarot/blob/7411a5520e8a00be6f5243a50c160e66ad285563/src/backend/starknet.cairo#L264
Vulnerability details
Among the ERC20 token behaviors in scope, there is
Doesn't revert on failure
that is not properly accounted for and has a unique root cause.The code in scope for the audit directly handles ERC-20s only in the following forms:
DualVmToken
wrapper.As we can see in the snippets from both cases, if the ERC-20 doesn't revert on failure, and instead returns
FALSE
, the protocol will interpret the failure as a successEVM protocols running in Kakarot are therefore at risk of having their accounting broken when interacting through
DualVmToken
with ERC-20s that don't revert on failures.A more unlikely, but still possible impact on the Kakarot native token, where Kakarot doesn't revert when failing to settle native tokens transactions, can be achieved when chaining this with other vulnerabilities that we reported separately.
Proof of Concept
FALSE
DualVmToken
wrapper for itDualVmToken.transferFrom()
EVM calltrue
despite the underlying returnedFALSE
Recommended Mitigation Steps
Consider adding checks for the values returned in the four instances highlighted above.
Assessed type
Other
The text was updated successfully, but these errors were encountered: