MorpheusAI

MorpheusAI
Foundry
22,500 USDC
View results
Submission Details
Severity: medium
Invalid

Lack of Approval Check in Stake Function Allows Unauthorized Token Transfers

Summary

The Distribution.sol:_Stake function in the smart contract allows users to deposit tokens directly to the contract without explicitly checking if the sender has approved the contract to spend tokens on their behalf.

Vulnerability Details

Missing Approval Check:
The Distribution.sol:_Stake function does not include a check to ensure that the sender has approved the contract to spend tokens on their behalf before initiating the transfer.
Without this approval check, users can unintentionally or maliciously send tokens to the contract, leading to a loss of tokens for
the sender.

uint256 balanceBefore_ = IERC20(depositToken).balanceOf(address(this));
IERC20(depositToken).safeTransferFrom(_msgSender(), address(this), amount_);
uint256 balanceAfter_ = IERC20(depositToken).balanceOf(address(this));

Impact

The vulnerability can result in a loss of tokens for users who inadvertently send tokens to the contract without proper approval.
Malicious contracts or actors could exploit this vulnerability to drain tokens from unsuspecting users' accounts.

Tools Used

Manual Review

Recommendations

Modify the stake function to include a check to ensure that the sender has approved the contract to spend tokens on their behalf before transferring tokens. This can be done using the allowance mechanism provided by ERC-20 tokens.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.