addFee will stop accumulating fee once rewardToken has reached max supply
The addFee function returns early when the reward token supply exceeds one billion, skipping the recording of trading fees. As a result, stakers lose their fee rewards and the fees become permanently locked in the contract.
Submitted by shenwilly, also found by 0x52, berndartmueller, GimelSec, GiveMeTestEther, kaden, Lambda, M0ndoHEHE, obront, Picodes, rbserver, reassor, rokinot, and scaraven
RewardDistributor will stop accumulating fees for staker rewards once rewardToken supply has reached the maximum supply (1 billion).
Vulnerability Details
RewardDistributor.sol#L98-L138
function addFee(address[2] memory addr, uint256 fee) public onlyTrader {
if (rewardToken.totalSupply() > 1000000000 * 10**18) {
// if supply is greater then a billion dont mint anything, dont add trades
return;
}
...
feesTrader[addr[0]][epoch] = feesTrader[addr[0]][epoch] + fee;
feesExchange[addr[1]][epoch] = feesExchange[addr[1]][epoch] + fee;
epochTotalFee[epoch] = epochTotalFee[epoch] + fee;
}
The check at the beginning of addFee is supposed to stop RewardDistributor from minting additional rewardToken once it has reached 1 billion supply. However, the current implementation has a side effect of causing the function to skip recording accumulated trading fees (the last 3 lines of the function). This will cause stakers to lose their trading fee rewards once the max supply has been reached, and the funds will be permanently locked in the contract.
Proof of Concept
- Alice staked
GOLOMto receive fee rewards fromRewardDistributor. GOLOMsupply reaches 1 billion token.- Traders keep trading on
GolomTrader, sending protocol fees toRewardDistributor. However,RewardDistributor.addFeedoes not update the fee accounting. - Alice won’t receive any fee reward and protocol fees are stuck in the contract.
Recommended Mitigation Steps
Modify addFee so that the check won’t skip accruing trade fees:
function addFee(address[2] memory addr, uint256 fee) public onlyTrader {
if (block.timestamp > startTime + (epoch) * secsInDay) {
uint256 previousEpochFee = epochTotalFee[epoch];
epoch = epoch + 1;
if (rewardToken.totalSupply() > 1000000000 * 10**18) {
emit NewEpoch(epoch, 0, 0, previousEpochFee);
} else {
uint256 tokenToEmit = (dailyEmission * (rewardToken.totalSupply() - rewardToken.balanceOf(address(ve)))) /
rewardToken.totalSupply();
uint256 stakerReward = (tokenToEmit * rewardToken.balanceOf(address(ve))) / rewardToken.totalSupply();
rewardStaker[epoch] = stakerReward;
rewardTrader[epoch] = ((tokenToEmit - stakerReward) * 67) / 100;
rewardExchange[epoch] = ((tokenToEmit - stakerReward) * 33) / 100;
rewardToken.mint(address(this), tokenToEmit);
epochBeginTime[epoch] = block.number;
if (previousEpochFee > 0) {
if (epoch == 1){
epochTotalFee[0] = address(this).balance; // staking and trading rewards start at epoch 1, for epoch 0 all contract ETH balance is converted to staker rewards rewards.
weth.deposit{value: address(this).balance}();
}else{
weth.deposit{value: previousEpochFee}();
}
}
emit NewEpoch(epoch, tokenToEmit, stakerReward, previousEpochFee);
}
}
feesTrader[addr[0]][epoch] = feesTrader[addr[0]][epoch] + fee;
feesExchange[addr[1]][epoch] = feesExchange[addr[1]][epoch] + fee;
epochTotalFee[epoch] = epochTotalFee[epoch] + fee;
return;
}
0xsaruman (Golom) resolved and commented:
Resolved in https://github.com/golom-protocol/contracts/commit/192e152dde2eed6c01a3945aa5fd223ff786ca5e
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
The early return in addFee skips the fee accounting updates when the reward token supply exceeds the maximum.
Impact
Stakers lose their trading fee rewards and the fees are permanently locked in the contract once the maximum supply is reached.
What the attacker needed
Reward token supply reaches 1 billion; traders continue trading
The fix
The issue was fixed by modifying addFee so that the supply check no longer skips accruing trade fees.
How it was found
- Alice stakes GOLOM to receive fee rewards.
- GOLOM supply reaches 1 billion tokens.
- Traders keep trading and send fees to RewardDistributor.
- addFee does not update fee accounting, so Alice receives no reward and fees are stuck.
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.
The contract stops adding up fees for stakers once a token reaches its maximum supply. Because of an early exit, the code that records fees is skipped, so the fees are never credited and stay stuck in the contract.
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.