An attacker can donate a certain amount of tokens to the Proxy contract and make the winners fewer tokens than intended.
Right now, the _distribute
function checks the latest balance of the tokens of the proxy contract.
which can be increased by donating some tokens to the contract.
The thing is when the contract is faced with multiple scenarios of accounting of different variables, the contract does not work as expected.
The contract suffers from rounding errors
where the invariant fails.
percentageShares of winners + CommissionFee == 10,000
Here are the things to note about the PoC :
As the attacker can easily manipulate the token balance of the contract, the fuzzing will include this as a parameter.
For simplicity, i've just included two winners and their percentages ( fuzz variables )
I kept the commission Fee constant for now which is 500
I've just shown two cases here but more can be generated.
Upon following values, the contract's invariant fails.
TotalTokensAmount | percentageOfWinner1 | percentageOfWinner2 | CommissionFee |
---|---|---|---|
400000000000000000000000 | 1098 | 8402 | 500 |
282776882385583792624126 | 1506 | 7994 | 500 |
These inputs are verified ✔
Loss of funds for users.
It is not very hard to exploit so the severity is high
Foundry, Manual review
Instead of checking directly the latest or instantaneous balance of the contract, maintain a state variable of tokenBalance
of tokens initialized to a certain value when the contract is created.
Use tokenBalance
instead of totalAmount
in the _distribute
function.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.