The removeOperators function in the OperatorStakingPool contract fails to actually transfer staked tokens back to operators when they are removed, despite updating internal accounting. This can lead to tokens being trapped in the contract and a mismatch between recorded and actual balances.
When an operator is removed via the removeOperators function, it calls the _withdraw function to handle any staked tokens:
However, the _withdraw function only updates internal accounting without transferring tokens:
This function updates share balances and emits a Withdraw event, but doesn't actually transfer any tokens to the operator.
Trapped Funds: Staked tokens remain in the contract after an operator is removed, potentially becoming inaccessible.
Accounting Discrepancy: The contract's internal accounting no longer matches its actual token balance.
Misleading Events: Withdraw events are emitted without corresponding token transfers.
Trust Issues: Operators may lose trust in the system if they can't retrieve their staked tokens upon removal.
The severity is high due to the potential for permanent loss of user funds and the fundamental misalignment between the contract's stated behavior and its actual operation.
The issue is caused by an incomplete implementation of the _withdraw function in the OperatorStakingPool contract. While it updates internal accounting, it fails to include the crucial step of transferring tokens back to the operator.
Admin adds an operator via addOperators.
Operator stakes 100 LST tokens.
Admin removes the operator via removeOperators.
The operator's internal balance is set to 0, and a Withdraw event is emitted.
However, the 100 LST tokens remain in the OperatorStakingPool contract.
The operator has no way to retrieve their staked tokens.
Make sure there is a code which transfer the operator funds, here is two suggestions I have:
Modify the _withdraw function to include an actual token transfer:
Add a separate function for operators to claim any remaining balance after removal, in case the automatic withdrawal fails:
By implementing these recommendations, the contract will ensure that operators can always retrieve their staked tokens, maintaining the integrity and trustworthiness of the staking system.
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.