Open hats-bug-reporter[bot] opened 1 year ago
I quote from the report:
Thus, a malicious beneficiary can transfer a large amount of tokens to inflate the surplus amount in such a way that the currentBalance() becomes zero
This does not seem possible. Can you elaborate on this?
In the test release()
is called after endTime
so it is normal that the contract is empty afterwards.
@bahurum thank you for the comment, I just wanted to illustrate that by manipulating the balance, the beneficiary can destroy the contract
I just wanted to illustrate that by manipulating the balance, the beneficiary can destroy the contract
It is not clear to me how that would work. The balance will not become 0 by sending tokens to the contract..
Github username: -- Submission hash (on-chain): 0x73f532fc256eb3c3a4764339bb847183b8d57b3491b9a3ab6c4cc3cf83350096 Severity: high
Description: Description\ TokenLock contract can be destroyed in an desirable way via a malicious beneficiary using a flashloan based attack.
Attack Scenario\ The function
withdrawSurplus()
is intented for a beneficiary to withdraw the surplus amount. This contract is designed in a way that lets the mentioned beneficiary to call the selfdestruct opcode via this function:If the
currentBalance()
becomes zero, then the beneficiary is able to destroy the contract.The function
currentBalance()
is:Also, there is not any protection for flashloan-based attacks in the contract. Thus, a malicious beneficiary can transfer a large amount of tokens to inflate the surplus amount in such a way that the
currentBalance()
becomes zero. Afterthat, the caller is able to destroy the contract although is not intended to be destroyed in that time and situation.Attachments
function withdrawSurplus(uint256 _amount) external override checkUserBlock onlyBeneficiary { if (_amount == 0) revert AmountCannotBeZero(); if (surplusAmount() < _amount) revert AmountRequestedBiggerThanSurplus();
}
function release() external override checkUserBlock onlyBeneficiary { uint256 amountToRelease = releasableAmount(); if (amountToRelease == 0) revert NoAmountAvailableToRelease();
}