Staking ETH on behalf of another user overwrites the previous value for the user receiving the staking assets.
The Steaking::stake
function allows staking raw ETH on behalf of another user. When user (user2) stakes assets on behalf of another user (user1), who had previously staked assets for himself, the previously stored value in the usersToStakes
variable for user1 will be overwritten with the new value from msg.value
from the transaction sent by user2.
Assets previously staked by user1 will no longer be tracked by the usersToStakes
variable, though they will still be included in the totalAmountStaked
variable. As a result, user1 will be unable to withdraw their originally staked assets and will only have access to the amount staked on their behalf by user2. In an edge case, user2 could reduce allocation of user1 to 0.5 ETH, which is the minimum stake amount.
user1 stakes 5 ETH, and this amount is assigned for him in the usersToStakes
variable
user2 then stakes 0.5 ETH on behalf of user1, which overwrites the previous value in the usersToStakes
variable. As a result, user1 is now only able to withdraw 0.5 ETH, instead of the originally staked 5 ETH.
Add the following code to the Steaking.t.sol
file within the SteakingTest
contract.
Manual Review
Foundry
Instead of setting a new value of the staked ETH, the amount form the msg.value
variable should be added to the previously staked ETH for that specific user.
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.