Repeated calls to multiStakerClaim in the same block leads to loss of funds
The reward distributor allowed the same staker reward to be claimed multiple times for one epoch if the claims occurred in the same block, because moving locked tokens to a new lock created a new token ID that bypassed the per-token claim check. An attacker could drain the contract's WETH balance by repeatedly claiming and merging locks within the epoch-changing block.
Submitted by Krow10
A malicious user can repeatedly claim the same staker reward for an epoch, provided the transactions all happen in the same block. This can effectively be done using services like Flashbots bundles and will result in the draining of the WETH balance of the RewardDistributor contract.
The idea is to bypass the require statement line 185 which checks if a claim has been already done for the epoch, for a specific token ID. By moving the locked tokens in a new lock, a new token ID will be generated and can be used to claim the rewards again, if the transaction happens in the same block for which the epoch is updated.
Indeed, when multiStakerClaim() is called, the rewardETH will be calculated from the amount of tokens locked in tokenids[tindex] at the block that triggered the epoch change (variable epochBeginTime). If, during this time, an attacker transfers its staked tokens to a new vault using the merge function of the VE token, the function will calculate the amount of staked tokens for the newly created tokenID as the same as the original tokenID reward.
A example abuse will look like this (pseudo-code adapted from the PoC) :
lockID = voteEscrow.create_lock(amount, 1 week); // Create lock #1 before
// IN THE BLOCK OF EPOCH CHANGE
rewardDistributor.multiStakerClaim([lockId], [0]); // Claim epoch 0 rewards for lock #1
voteEscrow.create_lock(1, 1 week); // Create lock #2 (requires 1 Golom token, could be created in advance)
voteEscrow.merge(lockId, lockId + 1); // Transfer lock #1 tokens to lock #2
rewardDistributor.multiStakerClaim([lockId + 1], [0]); // Claim same epoch rewards for lock #2
// repeat ...
To abuse this, the attacker needs to follow this steps:
- Have some locked Golom tokens.
- Wait for a
addFeecall that will trigger an epoch change (this can be monitored by looking at the mempool or predicted from block timestamps). Services like Flashbots also allows for specifying a range of blocks for bundles for better targeting. - Send a bundle of transactions to be included with the block containing the epoch changing transaction (see the PoC for an example of transactions).
Note that this needs to succeed only once to allow an attacker to drain all WETH funds so if the bundle isn’t included for a particular epoch, given the frequency of epoch changes, the bundle will eventually be included and trigger the exploit.
Proof of Concept
See warden’s original submission for full proof of concept.
Recommended Mitigation Steps
I initially thought about a few possible solutions:
- Checking a lock creation time to prevent claiming from locks created in the same block but the attacker can just create the blocks beforehand.
- Tracking the
msg.senderortx.originfor preventing multiple calls tomultiStakerClaimin the same block but the attacker can just send transactions from different addresses. - Preventing the merging of locks but the attacker can just create locks in advance and withdraw/add funds continuously between old/new locks.
None really fixes the vulnerability as it comes from the feature of locks being tradable meaning it’s not practically feasable to know if a lock has already be claimed by an individual just by looking at the lock ID.
A possible solution would be to find a way to prevent multiple calls to the same function within a block or better, make a checkpoint of the locks balances for each epochBeginTime and uses these values for calculating the rewards (instead of querying the VE contract in the loop).
0xsaruman (Golom) resolved and commented:
Removed
merge()Ref: https://github.com/golom-protocol/contracts/commit/b987077f2a227273bc7051e382bd55264162a77e
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 reward calculation queried the current locked balance per token ID at claim time instead of using a checkpoint of balances at the epoch start, so transferring tokens to a new token ID within the same block bypassed the per-token claim check.
Impact
An attacker could drain the WETH balance of the RewardDistributor contract, and the exploit only needs to succeed once.
What the attacker needed
Some locked Golom tokens; ability to submit a bundle in the epoch-changing block
The fix
The merge function was removed as a mitigation, though the report suggests checkpointing lock balances per epoch as a more robust fix.
How it was found
- Have some locked Golom tokens.
- Wait for an addFee call that triggers an epoch change, monitoring the mempool or predicting from block timestamps.
- Send a bundle of transactions to be included with the block containing the epoch-changing transaction.
- In that block, claim rewards for the original lock ID.
- Create a new lock and merge the original lock's tokens into it.
- Claim the same epoch's rewards again for the new lock ID, repeating as needed.
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.
A smart contract paid rewards based on which locked tokens you held at a certain moment. The check that stopped you claiming twice only looked at the token ID, so if you moved your locked tokens into a new token ID within the same block, you could claim again. Doing this repeatedly in one block let an attacker take more rewards than they were owed.
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.