Platform: Code4rena
Start Date: 04/02/2022
Pot Size: $30,000 USDC
Total HM: 3
Participants: 37
Period: 3 days
Judge: leastwood
Id: 84
League: ETH
Rank: 13/37
Findings: 1
Award: $625.19
🌟 Selected for report: 0
🚀 Solo Findings: 0
Sale participants will only be able to claim their CTDL tokens once the sale is finalized. However, there is no guarantee that it ever will be, because:
saleEnded()
will always be false. Eg. setting long sale duration or a very distant future sale start time.function finalize() external onlyOwner { require(!finalized, "TokenSale: already finalized"); require(saleEnded(), "TokenSale: not finished"); require( tokenOut.balanceOf(address(this)) >= totalTokenOutBought, "TokenSale: not enough balance" ); finalized = true; emit Finalized(); }
The core issue is that users’ funds are immediately accessible by the sale recipient at the moment of purchase while they have to wait for the sale to be complete before receiving their tokens. From a sale participant’s POV, he will feel that the organization can at anytime choose not to fulfil their end of the sale (ie. get rugged).
// have following require statement in setSaleStart() // possibly in setSaleDuration() and setTokenInLimit() as well // but it might be intended to have the sale extended / ended prematurely require(block.timestamp < saleStart, "TokenSale: sale has already begun");
uint64 internal LIMIT = 1 year; // in setSaleDuration() require(_saleDuration < LIMIT, "TokenSale: exceed limit");
onlyOwner
restriction.While token claiming can still be done after the sale, a check can be added to ensure the CTDL balance of the contract is at least the totalTokenOutBought
in the purchase.
function buy() { ... totalTokenOutBought += tokenOutAmount_; require(tokenOut.balanceOf(address(this)) >= totalTokenOutBought, "insufficient balance"); ... }
In this less ideal scenario, have the funds transferred to an escrow contract. Should users not receive CTDL tokens after a certain time, users are entitled to reclaim their funds.
#0 - GalloDaSballo
2022-02-14T13:07:26Z
This ultimately is a DOS / Hostage of funds that can happen.
I believe this is simply because of the permission call to finalize
Arguably that means this is admin privilege so I'd downgrade to medium, but fully acknowledge the finding
#1 - 0xleastwood
2022-03-14T10:57:20Z
Duplicate of #50
#2 - 0xleastwood
2022-03-16T12:45:50Z
Duplicate of #61