Lucene search

K
code423n4Code4renaCODE423N4:2023-08-LIVEPEER-FINDINGS-ISSUES-145
HistorySep 06, 2023 - 12:00 a.m.

An attacker can manipulate the total active stake before calling reward() to get more rewards

2023-09-0600:00:00
Code4rena
github.com
3
attack
rewards
stake manipulation
vulnerability
mitigation
transcoders

Lines of code

Vulnerability details

Impact

Attackers could drain rewards meant for other transcoders.

Proof of Concept

The key vulnerable code is in the reward() function:<https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/bonding/BondingManager.sol#L881-L882&gt;
This uses the transcoder’s total stake (earningsPool.totalStake) and the total active stake (currentRoundTotalActiveStake) to determine the transcoder’s portion of the rewards.

An attacker who is a transcoder could temporarily increase their stake before calling reward() by bonding more tokens or transferring bonds from another account they control. This would increase earningsPool.totalStake and get them a larger portion of the totalRewardTokens.

Then in updateTranscoderWithRewards(), the attacker’s cumulative rewards are increased by the full amount of _rewards: t.cumulativeRewards = t.cumulativeRewards.add(transcoderRewardStakeRewards).add(transcoderCommissionRewards);
After claiming the rewards, the attacker could decrease their stake back to the original amount. This would allow them to unfairly claim a larger portion of rewards than they should based on their true stake

Tools Used

Manual

Recommended Mitigation Steps

A snapshot of the total active stake should be taken before reward() is called, and that snapshot value should be used in the reward calculation instead of currentRoundTotalActiveStake.

Assessed type

Other


The text was updated successfully, but these errors were encountered:

All reactions