tokenBalanceOfAddress of nftOwner becomes permanently incorrect after arbRestake
The arbRestake function reduces an NFT's stake shares but does not update the owner's addressShares, so tokenBalanceOfAddress reports an inflated balance that persists even after the NFT is transferred. An attacker could exploit this to show a false higher balance, potentially affecting reward calculations or other logic that relies on the reported balance.
Submitted by hyh, also found by GreyArt and hack3r-0m
Successful arbRestake performs _redeemShares for arbRewardShares amount to extract the arbitrager reward. This effectively reduces shares accounted for an NFT, but leaves untouched the addressShares of an nftOwner.
As a result the tokenBalanceOfAddress function will report an old balance that existed before arbitrager reward was slashed away. This will persist if the owner will transfer the NFT to someone else as its new reduced shares value will be subtracted from addressShares in _beforeTokenTransfer, leaving the arbitrage removed shares permanently in addressShares of the NFT owner, essentially making all further reporting of his balance incorrectly inflated by the cumulative arbitrage reward shares from all arbRestakes happened to the owner’s NFTs.
Proof of Concept
arbRestake redeems arbRewardShares, which are a part of total shares of an NFT:
This will effectively reduce the stakeShares:
But there is no mechanics in place to reduce addressShares of the owner apart from mint/burn/transfer, so addressShares will still correspond to NFT shares before arbitrage. This discrepancy will be accumulated further with arbitrage restakes.
Recommended Mitigation Steps
Add a flag to _redeemShares indicating that it was called for a partial shares decrease, say isPartialRedeem, and do addressShares[nftOwner] -= _stakeShares when isPartialRedeem == true.
Another option is to do bigger refactoring, making stakeShares and addressShares always change simultaneously.
Evert0x (Sherlock) confirmed and commented:
This is a legit issue and needs to be addressed. I think we choose to delete this functionality all together.
The function has some potential future benefit but it might be too little benefit to make these relatively complex changes that make the code harder to understand.
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 _redeemShares function, when called during arbRestake, reduces stakeShares but does not correspondingly reduce addressShares for the NFT owner.
Impact
The tokenBalanceOfAddress function reports an inflated balance that persists and accumulates with each arbRestake, potentially leading to incorrect reward calculations or other logic errors.
What the attacker needed
The owner must have an NFT with shares; arbRestake must be called on that NFT
The fix
The functionality was removed altogether, as confirmed by the project; alternatively, the fix would be to update addressShares when _redeemShares is called for a partial decrease.
How it was found
- Call arbRestake, which redeems arbRewardShares and reduces the NFT's stakeShares.
- Observe that addressShares for the NFT owner is not reduced.
- Call tokenBalanceOfAddress and see an inflated balance.
- Transfer the NFT; the reduced shares are subtracted from addressShares, leaving the discrepancy permanent.
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.
In this system, each NFT has a number of 'shares' that represent its value. The contract also keeps a separate record of how many shares each owner has. When a function called arbRestake takes away some shares from the NFT, it forgets to update the owner's record. So the owner's reported balance stays too high, and this error sticks even if the NFT is sold.
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.