Return value of transfer
and transferFrom
not checked in DualVmToken
contract
#42
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-51
🤖_primary
AI based primary recommendation
🤖_23_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
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
Vulnerability details
Impact
As per the ERC20 token behaviors in scope,
Doesn't revert on failure In scope
is a behavior that is in scope. This behavior is related to this issue.The
transfer
andtransferFrom
functions in theDualVmToken
contract do not check the return value of the function of theERC20
contract. This can lead to a situation where thetransfer
ortransferFrom
function of theERC20
contract ( on starknet ) fails, but thetransfer
ortransferFrom
function of theDualVmToken
contract still returnstrue
. This can lead to a situation where theDualVmToken
contract is in an inconsistent state.For reference,
_transfer
function is as follows:The
transferFrom
function is as follows:It can be seen that both these functions doesn't check the return value of the
starknetToken.delegatecallCairo
function.Proof of Concept
Consider the following scenario:
transfer
function of theERC20
contract ( on starknet ) doesn't revert but returnsfalse
when the transfer fails.DualVmToken
contract calls thetransfer
function of theERC20
contract.DualVmToken
contract doesn't check the return value of thetransfer
function of theERC20
contract.transfer
function of theERC20
contract fails but theDualVmToken
contract still returnstrue
.Tools Used
Manual code review
Recommended Mitigation Steps
The return value of the
starknetToken.delegatecallCairo
function should be checked in the_transfer
and_transferFrom
functions of theDualVmToken
contract to ensure that theDualVmToken
contract is in a consistent state.Assessed type
ERC20
The text was updated successfully, but these errors were encountered: