20,000 USDC
View results
Submission Details
Severity: high
Valid

WETH deposited before the contract gets any staked tokens can get permanently locked

Summary

Any WETH deposited while there are no staking tokens in the system can be permanently locked by calling claim().

Vulnerability Details

The claim() function sets the internal accounting balance of the contract to the actual WETH balance of the contract. This becomes an issue when there is a discrepancy between the balance and the internal accounting due to a WETH refill in the contract. In the case that it gets called during a case where there are no collateral tokens in the protocol the funds will be lost forever because there will not be an index increment because of them.

Consider the following PoC clearly demonstrating the issue:

https://gist.github.com/CrisCodesCrap/092f87c74221549526d816fd9e4c6033

Impact

The funds deposited at that time will be locked forever.

Tools Used

Manual Review

Recommendations

Consider adding some protection to the claim(), and how it can be called. Also consider not setting the internal accounting to the current balance, but to the old accounting amount - the claimed amount.

balance = balance - claimedAmount;

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.