OperatorVCS.updateDeposits(bytes)Path: contracts/linkStaking/OperatorVCS.sol#159-223
Description:
token.safeTransfer(address(stakingPool), balance) in the OperatorVCS.sol, which transfers tokens to the stakingPool. Since this involves an interaction with an external contract (stakingPool), there is a potential risk of a reentrant call during the token transfer. The contract state variables (totalDeposits, totalPrincipalDeposits) are updated only after the external call is completed, making the contract vulnerable if stakingPool is malicious and attempts reentrancy.
Code:
VaultDepositController._depositToVaults(uint256,uint256,uint256,uint64[]).The contract’s state variables group.totalDepositRoom and toDeposit are updated only after the call to vault.deposit(uint256), which makes the contract vulnerable if vault becomes malicious. A malicious vault could exploit this by causing multiple deposit failures, draining all funds and future deposits.
VaultDepositController.withdraw(uint256,bytes)vault.withdraw(deposits) is called before updating unbondedRemaining, which impacts the subsequent state variable totalDeposits, making the contract vulnerable with reentrancy.VaultDepositController.withdraw(uint256,bytes)token.safeTransfer(msg.sender, totalWithdrawn) called before update state variables totalUnbonded,totalPrincipalDeposits,group.totalDepositRoom,vaultGroups[], making the contract vulnerable with reentrancy.VaultControllerStrategy.updateDeposits(bytes).token.safeTransfer(address,uint256) called before update state variable totalDeposits, making the contract vulnerable with reentrancy.A reentrancy attack could potentially lead to an inconsistent state in the contract, where accounting variables do not reflect the actual balance, which might be exploited for financial gain.
To mitigate reentrancy risks:
Use a reentrancy guard, such as ReentrancyGuard from OpenZeppelin, to protect the function.
Alternatively, move the state updates (totalDeposits and totalPrincipalDeposits) before the external call to safeTransfer, ensuring the contract is in a consistent state before making external interactions.
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.