MarsellusWallace - Insecure Token Transfer Methods #9
Labels
Excluded
Excluded by the judge without consulting the protocol or the senior
Non-Reward
This issue will not receive a payout
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
MarsellusWallace
Medium
Insecure Token Transfer Methods
Summary
Ser Marry
Vulnerability Detail
The contract contains several functions (
claimWithdraw
,claim_
, andfinishDistribution
) that interact with ERC20 tokens. These functions use the.transfer
method for sending tokens, However, the.transfer
method does not throw an exception or revert the transaction if the transfer fails. Instead, it simply returns a boolean indicating success or failure. If the recipient of the transfer is a contract that does not handle ERC20 token transfers correctly (i.e., it does not have a fallback function that can accept ERC20 tokens), the.transfer
call will succeed from the perspective of the calling contract, but the tokens will not be received by the intended recipient. This leads to a silent failure, where the contract believes the transfer was successful, but in reality, the tokens were not moved.Example Code Snippet:
Also in
claim_
function:And in the
finishDistribution
function:In the above snippet, the
claimWithdraw
function usesreward.transfer(account, claimAmount)
to send tokens to an account. If account is a contract that does not handle ERC20 tokens correctly, this transfer will fail silently.Impact
The primary impact of this vulnerability is the potential loss of tokens. Users expecting to receive their rewards may find that their balances remain unchanged, leading to confusion and frustration. Additionally, this vulnerability could be exploited by attackers to drain tokens from the contract under certain conditions, such as if the contract is tricked into sending tokens to a malicious contract controlled by an attacker.
Code Snippet
StakedEXA.sol#L202
StakedEXA.sol#L195
StakedEXA.sol#L390
StakedEXA.sol#L394
StakedEXA.sol#L431
Tool used
Manual Review
Recommendation
The contract should use the
SafeERC20
library'ssafeTransfer
method instead of the native.transfer
method. TheSafeERC20
library checks if the recipient is a contract and, if so, calls its fallback function instead of directly sending tokens. This ensures that the contract behaves correctly even when interacting with other contracts.The text was updated successfully, but these errors were encountered: