UserManager : totalStaked ≥ totalFrozen should be checked before and after totalFrozen is updated
The contract's updateTotalFrozen and batchUpdateTotalFrozen functions only check that totalStaked is at least totalFrozen before updating, not after. An attacker could potentially break the invariant that totalStaked remains greater than or equal to totalFrozen, compromising system integrity.
Submitted by itsmeSTYJ
The require statement in updateTotalFrozen and batchUpdateTotalFrozen to check that totalStaked ≥ totalFrozen should be done both before and after _updateTotalFrozen is called to ensure that totalStake is still ≥ totalFrozen. This will serve as a sanity check to ensure that the integrity of the system is not compromised.
GalloDaSballo (judge) commented:
Agree with the finding and the recommendation of adding an additional require to ensure protocol invariants aren’t broken
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the check for totalStaked ≥ totalFrozen is only performed before the update, not after, allowing the invariant to be violated.
Impact
The integrity of the system could be compromised if the invariant is broken, though no specific exploit is described.
What the attacker needed
None
The fix
An additional require statement should be added after the update to ensure the invariant holds.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Smart contracts often rely on rules that must always hold true, called invariants. Here, the rule is that the total amount staked must never be less than the total amount frozen. The code only checks this rule before changing the frozen amount, so a bug could leave the system in an invalid state.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.