Beginner FriendlyFoundryDeFi
100 EXP
View results
Submission Details
Severity: high
Valid

Staking Amount Overwriting

Summary

The stake function in the Steaking contract replaces the existing staked amount for a user with the new stake value, rather than incrementing it.

Vulnerability Details

The current implementation of the stake function overwrites the staked amount for the _onBehalfOf address with the new amount:

self.usersToStakes[_onBehalfOf] = msg.value

Instead of adding the new stake to the existing amount, this assignment completely replaces the previous balance with msg.value. As a result, if a user stakes multiple times, their earlier stakes are lost and replaced with the most recent amount.

Impact

This behavior prevents users from incrementally increasing their staked balance. Instead of aggregating stakes, each new stake replaces the previous one, leading to inaccurate tracking of the total staked amount. This can cause incorrect points calculations and potential issues with rewards distribution or staking history.

Tools Used

Manual Code Review

Recommendations

Update the stake function to increment the existing stake rather than replacing it, ensuring that users can increase their stake progressively.

Updates

Lead Judging Commences

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Validated
Assigned finding tags:

Steaking::stake overwrites the msg.value into storage

Support

FAQs

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