On the logic in updateFor():
Currently, it only considers the case where the balance increases but never decreases.
This breaks the proportionality in the index if a user withdraws tokens.
The logic should be updated to proportionally decrease the index when the balance decreases.
POC
EXPLANATION POC:
The key steps validating the vulnerability are:
An initial deposit of 10 ETH is made.
Time is advanced to update the index.
A partial withdrawal of 5 ETH is made.
It is verified that the supplyIndex is 0.
Also, the global index is 0.
Therefore, both indices remain the same after the partial withdrawal when they should be different. This demonstrates that supplyIndex is not updated correctly, proving the vulnerability in updateFor().
The logic of updateFor() does not consider the case where the balance might decrease. If a user withdraws some tokens, the supply rate should decrease proportionally. Currently it only increases.
An attacker could exploit this by depositing a large amount, getting a high rate, then withdrawing tokens but keeping the rate artificially high. This would allow him to steal bounties.
manual review
Some improvements that could be made:
Calculate the expected index after withdrawal based on the new balance and compare it with the obtained index.
Test with different withdrawal amounts to validate in different scenarios.
Some improvements that could be made:
Calculate the expected index after withdrawal based on the new balance and compare it with the obtained index.
Test with different withdrawal amounts to validate in different scenarios.
But essentially, it demonstrates that the index is not updated properly when the balance decreases, which is precisely the issue reported in updateFor().
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.