Platform: Code4rena
Start Date: 03/05/2023
Pot Size: $60,500 USDC
Total HM: 25
Participants: 114
Period: 8 days
Judge: Picodes
Total Solo HM: 6
Id: 234
League: ETH
Rank: 113/114
Findings: 1
Award: $15.58
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: aviggiano
Also found by: 0xSmartContract, 0xTheC0der, 0xcm, ABAIKUNANBAEV, Audinarey, Audit_Avengers, BGSecurity, Bauchibred, Dug, Evo, Haipls, Jerry0x, TS, bytes032, devscrooge, kenta, ladboy233, mrvincere, patitonar, sakshamguruji, tsvetanovv
15.5756 USDC - $15.58
Whenever a user Stakes their NFT , they are awarded reward in Ajna Tokens for Updating Bucket Exchange Rate as well as interest earned by keeping their NFT in the contract . While reviewing the RewardsManager.sol
, the function _transferAjnaRewards
caught my attention.
The problem is
if (rewardsEarned_ > ajnaBalance) rewardsEarned_ = ajnaBalance;
, as it completely destroys the additiona extra reward tokens if the reward token exceeds the current ajnaBalance.
This can lead to griefing attacks where user's loose parts of their reward tokens as some malicious actor spreads some news and because of the impact of the news, everyone starts calling the contract at the same time to withdraw their rewards and NFTs .
ajnaBalance
decreases and multiple users with huge rewards will start getting lose of rewards as if the rewardsEarned_ > ajnaBalance
then rewardsEarned = ajnaBalance
and all the remaining balance of rewardsEarned
get's lost.Manual Analysis
It will be better if there is a check before calling the _transferAjnaRewards()
to check for ajnaBalance
and if it is less than rewardsEarned
, the function does not get's called .
Another remediation would be to handle the rewardsEarned_ = ajnaBalance;
with a different logic to prevent the reward tokens loss of users.
Other
#0 - c4-judge
2023-05-12T10:34:46Z
Picodes marked the issue as duplicate of #361
#1 - c4-judge
2023-05-29T20:57:56Z
Picodes marked the issue as satisfactory