The updateStrategyRewards function in the provided Solidity code incorrectly checks if a strategy exists for msg.sender instead of verifying the existence of the strategy by its ID.
https://github.com/Cyfrin/2024-09-stakelink/blob/main/contracts/core/StakingPool.sol#L413-L417
Function: updateStrategyRewards
Issue: The function checks if msg.sender is authorized by verifying if a strategy exists for msg.sender. This is incorrect as it should check the strategy ID instead.
function below fails as check in if statement assesses the msg.sender instead of each strategy in _strategyIdxs
medium
manual review
Modify the function to check the existence of the strategy by its ID rather than msg.sender.
```solidity
function updateStrategyRewards(uint256[] memory _strategyIdxs, bytes memory _data) external {
++for (uint256 i = 0; i < _strategyIdxs.length; i++) {
++uint256 strategyId = _strategyIdxs[i];
++if (msg.sender != rebaseController && !_strategyExists(strategyId))
revert SenderNotAuthorized();
}
_updateStrategyRewards(_strategyIdxs, _data);
}
```
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.