Improper control over the versions of distributions’ metadata may lead to repeated claims of rewards
The admin role can call updateRewardsMetadata to reset the claimed tracker, allowing a user to claim rewards again after a metadata update. If the admin accidentally sends two identical update transactions, a user could claim twice.
Submitted by WatchPug
function updateRewardsMetadata(Common.Distribution[] calldata distributions)
external
onlyRole(DEFAULT_ADMIN_ROLE)
{
require(distributions.length > 0, "Invalid distributions");
IRewardDistributor(distributor).updateRewardsMetadata(distributions);
}
In the current implementation, DEFAULT_ADMIN_ROLE of BribeVault can call updateRewardsMetadata() to update the rewards metadata for the specified identifiers.
When a distribution’s metadata is updated, it will also increase the updateCount and reset the claimed tracker.
RewardDistributor.sol#L97-L119
function updateRewardsMetadata(
Common.Distribution[] calldata _distributions
) external {
require(msg.sender == bribeVault, "Invalid access");
require(_distributions.length > 0, "Invalid _distributions");
for (uint256 i = 0; i < _distributions.length; i++) {
// Update the metadata and also increment the update to reset the claimed tracker
Reward storage reward = rewards[_distributions[i].rewardIdentifier];
reward.token = _distributions[i].token;
reward.merkleRoot = _distributions[i].merkleRoot;
reward.proof = _distributions[i].proof;
reward.updateCount += 1;
emit RewardMetadataUpdated(
_distributions[i].rewardIdentifier,
_distributions[i].token,
_distributions[i].merkleRoot,
_distributions[i].proof,
reward.updateCount
);
}
}
However, when the network is congested, DEFAULT_ADMIN_ROLE of BribeVault may mistakenly send 2 updateRewardsMetadata() txs, and the transactions can be packaged into different blocks.
Let’s say there 2 updateRewardsMetadata() tx with the same calldata, if someone claims rewards in between the two txs, then they can claim again after the second transaction.
Proof of Concept
Given:
distributionA’s proof is set wrong intransferBribes()Aliceis eligible for rewards indistributionA- the network is congested
- current block number = 10000
DEFAULT_ADMIN_ROLEofBribeVaulttries to callupdateRewardsMetadata()and updatedistributionA’s proof;- After a while, since the prev tx is stucked,
DEFAULT_ADMIN_ROLEofBribeVaultcallsupdateRewardsMetadata()again with same calldata; - The first tx got packed into block 10010;
Alicecallsclaim()and got the reward;- The 2nd tx got packed into block 10020;
Alicecallsclaim()again and get the reward again.
Recommended Mitigation Steps
Change to:
struct UpdateDistribution {
bytes32 rewardIdentifier;
address token;
bytes32 merkleRoot;
bytes32 proof;
uint256 prevUpdateCount;
}
function updateRewardsMetadata(
Common.UpdateDistribution[] calldata _distributions
) external {
require(msg.sender == bribeVault, "Invalid access");
require(_distributions.length > 0, "Invalid _distributions");
for (uint256 i = 0; i < _distributions.length; i++) {
require(reward.updateCount == _distributions[i].prevUpdateCount, "Invalid updateCount");
// Update the metadata and also increment the update to reset the claimed tracker
Reward storage reward = rewards[_distributions[i].rewardIdentifier];
reward.token = _distributions[i].token;
reward.merkleRoot = _distributions[i].merkleRoot;
reward.proof = _distributions[i].proof;
reward.updateCount += 1;
emit RewardMetadataUpdated(
_distributions[i].rewardIdentifier,
_distributions[i].token,
_distributions[i].merkleRoot,
_distributions[i].proof,
reward.updateCount
);
}
}
kphed (Redacted Cartel) disputed and commented:
However, when the network is congested, DEFAULTADMINROLE of BribeVault may mistakenly send 2 updateRewardsMetadata() txs, and the transactions can be packaged into different blocks.
The tx is executed via a multisig - we won’t accidentally call it twice.
After a while, since the prev tx is stucked, DEFAULTADMINROLE of BribeVault calls updateRewardsMetadata() again with same calldata;
In the scenario where we wanted to call
updateRewardsMetadataagain with the same calldata, we would use the same nonce as the stuck transaction.
Alex the Entreprenerd (judge) decreased severity to Medium and commented:
I agree with both the warden and the sponsor in that I believe that:
- the
DEFAULT_ADMIN_ROLEcan set metadata back to allow further (arbitrary) claims- This can be used by the admin to grief or alter the claimable rewards
At the same time I have to agree that the Sponsor wouldn’t be calling this “accidentally”.
I believe this finding to be valid, and to shed light into Admin Privilege, in that the Admin can set the metadata to whatever they want, allowing or denying claims at their will.
As such I believe the finding to be valid, and Medium Severity to be more appropriate.
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 update function does not check the current update count, so replaying the same update resets the claimed tracker and allows repeated claims.
Impact
A user could claim rewards multiple times if the admin accidentally sends duplicate update transactions, but the sponsor says this would not happen because they use a multisig and would reuse the nonce.
What the attacker needed
Admin sends duplicate update transactions; network congestion causes first tx to be stuck; user claims between the two transactions
The fix
The update function should require the caller to provide the current update count and check it matches, preventing replay of the same update.
How it was found
- Admin calls updateRewardsMetadata to fix a wrong proof for a distribution.
- The transaction gets stuck due to network congestion.
- Admin calls updateRewardsMetadata again with the same calldata.
- The first transaction is mined and the user claims the reward.
- The second transaction is mined, resetting the claimed tracker.
- The user claims the reward again.
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 lets an admin update reward details, and each update resets who has claimed. If the admin sends the same update twice by mistake, a user can claim their reward once after the first update and again after the second. This is like a shopkeeper accidentally resetting the 'already collected' list twice, letting someone take two free samples.
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.