Open github-actions[bot] opened 1 year ago
Fixed https://github.com/kree-dotcom/Velo-Deposit-Tokens/commit/23ff5653b555b11c9f4dead7ff5a72d50eac5788
Here we have added a check on line 81 and 122 as suggested. There is also minor refactoring which is needed due to the fact if we are doing a partial withdrawal then after calling depositReceipt.split()
the owner of the newly acquired depositReceipt is the Depositor not the original msg.sender. Therefore we moved the withdrawal logic to an internal function that both withdrawFromGauge()
and partialWithdrawFromGauge()
both access after ownership checks.
Fixes look good. Splits withdrawFromGauge into to an internal and external function with the external function checking for NFT ownership.
0x52
high
Anyone can withdraw user's Velo Deposit NFT after approval is given to depositor
Summary
Depositor#withdrawFromGauge
is a public function that can be called by anyone which transfers token tomsg.sender
.withdrawFromGauge
burns the NFT to be withdrawn, which means thatDepositor
must either be approved or be in possession of the NFT. Since it doesn't transfer the NFT to the contract before burning the user must either send the NFT to theDepositor
orapprove
theDepositor
in a separate transaction. After the NFT is either transferred or approved, a malicious user could withdraw the NFT for themselves.Vulnerability Detail
Depositor#withdrawFromGauge
allows anyone to call it, burning the NFT and sendingmsg.sender
the withdrawn tokens.Depositor
callsDepositReceipt_Base#burn
, which means that it must be either the owner or approved for the NFT. SinceDepositor#withdrawFromGauge
doesn't transfer the NFT from the user, this must happen in a separate transaction. Between the user approval/transfer and them callingDepositor#withdrawFromGauge
a malicious user could callDepositor#withdrawFromGauge
first to withdraw the NFT and steal the users funds. This would be very easy to automate with a bot.Example:
User A
deposits 100 underlying into theirDepositor
and is givenToken A
which represents their deposit. After some time they want to redeemToken A
so theyApprove
theirDepositor
forToken A
.User B
sees the approval and quickly callsDepositor#withdrawFromGauge
to withdrawToken A
.User B
is sent the 100 tokens andToken A
is burned fromUser A
.Impact
Users attempting to withdraw can have their funds stolen
Code Snippet
https://github.com/sherlock-audit/2022-11-isomorph/blob/main/contracts/Velo-Deposit-Tokens/contracts/Depositor.sol#L119-L127
Tool used
Manual Review
Recommendation
Only allow owner of NFT to withdraw it: