Staking: the rebase function needs to be called before calling the function in the Yieldy contract that uses the rebasingCreditsPerToken variable
The Staking contract's unstake, claim, and claimWithdraw functions call Yieldy functions that rely on the rebasingCreditsPerToken variable without first triggering the rebase for the current epoch. This could cause users to receive incorrect token balances or credits during those operations.
Submitted by cccz
In the Yieldy contract, functions such as balanceOf/creditsForTokenBalance/tokenBalanceForCredits/transfer/transferFrom/burn/mint will use the rebasingCreditsPerToken variable, so before calling these functions in the Staking contract, make sure that the rebase of this epoch has occurred. Therefore, the rebase function should also be called in the unstake/claim/claimWithdraw function of the Staking contract.
Proof of Concept
Recommended Mitigation Steps
function claim(address _recipient) public {
Claim memory info = warmUpInfo[_recipient];
+ rebase();
...
function claimWithdraw(address _recipient) public {
Claim memory info = coolDownInfo[_recipient];
+ rebase();
...
function unstake(uint256 _amount, bool _trigger) external {
// prevent unstaking if override due to vulnerabilities asdf
require(!isUnstakingPaused, "Unstaking is paused");
- if (_trigger) {
rebase();
- }
toshiSat (Yieldy) confirmed and resolved
Yes, seems like a logic flaw, makes sense as Medium.
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 Staking contract calls Yieldy balance and transfer functions that depend on rebasingCreditsPerToken without first calling rebase for the current epoch.
Impact
Users could receive incorrect balances or credits when unstaking or claiming if the rebase for the epoch has not yet occurred.
What the attacker needed
A staking position in the contract; rebase not yet called for the epoch
The fix
The report recommends calling rebase at the start of claim, claimWithdraw, and unstake, and the finding was confirmed and resolved.
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.
Some tokens change everyone's balance automatically over time, like interest being added. The contract keeps a shared number that says how many tokens each credit is worth, and that number is only updated when a 'rebase' step runs. If you withdraw or claim before that update, the contract may calculate your amount using an old number, so you could get the wrong amount.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.