Fully slashed transcoder can vote with 0 weight messing up the voting calculations
A fully slashed transcoder can still vote with zero weight, and when a delegator later tries to override that vote, the system subtracts the delegator's weight from other voters, potentially reverting the transaction and blocking the delegator from voting.
Submitted by Vagner (1, 2), also found by ladboy233
If a transcoder gets slashed fully he can still vote with 0 amount of weight making any other delegated user that wants to change his vote to subtract their weight amount from other delegators/transcoders.
Proof of Concept
In BondingManager.sol any transcoder can gets slashed by a specific percentage, and that specific transcoder gets resigned and that specific percentage gets deducted from his bondedAmount.
https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/bonding/BondingManager.sol#L394-L411
If any bondedAmount will remain then the penalty will also gets subtracted from the delegatedAmount, if not, nothing happens.
https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/bonding/BondingManager.sol#L412-L417
After that the penalty gets burned and the fees gets paid to the finder, if that is the case.
https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/bonding/BondingManager.sol#L420-L440
The problem relies in the fact that a fully slashed transcoder, even if it gets resigned, he is still seen as an active transcoder in the case of voting. Let’s assume this case:
- A transcoder gets fully slashed and gets resigned from the transcoder pools, getting his
bondedAmountto 0, but he still hasdelegatedAmountto his address since nothing happens this variable. https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/bonding/BondingManager.sol#L402-L418 - Transcoder vote a proposal and when his weighting gets calculated here, it will use the
_getVotesfromGovernorVotesUpgradeable.sol. https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable/blob/f34a3a7e5a1d698d87d517fda698d48286310bee/contracts/governance/extensions/GovernorVotesUpgradeable.sol#L55-L61 _getVotescallsgetPastVotesonBondingVotes.solhttps://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/bonding/BondingVotes.sol#L167-L170 which returns the amount of weight specific to this transcoder and as you can see, because the transcoder has abondedAmountequal to 0, the first if statement will be true and 0 will be returned. https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/bonding/BondingVotes.sol#L372-L373- 0 weight will be passed into
_countVotewhich will then be passed into_handleVoteOverrides. https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/treasury/GovernorCountingOverridable.sol#L151 - Then it will check if the caller is a transcoder, which will be true in our case, because nowhere in the
slashTranscoderfunction, or any other function the transcoderdelegateAddressgets changed, so this if statement will be true https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/treasury/GovernorCountingOverridable.sol#L182-L184, which will try to deduct the weight from any previous delegators. https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/treasury/GovernorCountingOverridable.sol#L184-L189 - If any delegator already overridden any amount this subtraction would revert, but if that is not the case, 0 weight will be returned, which is then used to vote
for,against,abstain, but since 0 weight is passed no changed will be made. - Now the big problem arise, if any delegator that delegated their votes to this specific transcoder want to change their vote, when his weight gets calculated,
delegatorCumulativeStakeAtgets called https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/bonding/BondingVotes.sol#L459-L487 which will return most of the time hisbondedAmount, amount which is greater than 0, since he didn’t unbound. - Because of that when
_handleVoteOverridesgets called in_countVote, to override the vote, this if statement will be true, since the transcoder voted already, but with 0 weight https://github.com/code-423n4/2023-08-livepeer/blob/a3d801fa4690119b6f96aeb5508e58d752bda5bc/contracts/treasury/GovernorCountingOverridable.sol#L195 and the delegator weight gets subtracted from the support that the transcoder used in his vote. - The system in this case expects the transcoder to vote with the whole
delegatedAmount, which will make the subtraction viable, since the weight of the delegator should be included in the fulldelegatedAmountof that specific transcoder, but since the transcoder voted with 0 weight, the subtraction would be done from other delegators/transcoders votes. - Also this can be abused by a transcoder by voting a category which he knows will not get a lot of votes, if let’s say a transcoder used his 0 weight to vote for
abstainand every other voter will vote onfororagainst, every time one of his delegators want to change the vote the subtraction can revert, which will force those delegators out of the vote, until they will change their transcoder.
Recommended Mitigation Steps
If a transcoder gets fully slashed and resigned, delete his address from delegateAddress so he will not appear as a transcoder in the mechanism of counting the votes. If he still wants to participate in the system he can act as a delegator to another transcoder. Another solution would be to not let 0 weight votes happen, since they don’t modify the vote state at all.
Assessed type
Governance
victorges (Livepeer) confirmed and commented:
Slashing is turned off in the protocol, so this specific issue is not that important. It did point towards an issue in
BondingVotesthough in the way that thegetBondingStatefunction checks if transcoder is a transcoder or not and defaults to 0 whenbondedAmountis0. There are other ways that this logic can be triggered (not throughslashTranscoder) that can show inconsistencies as well, so I’m flagging this as valid for the underlying issue that it hints to, even though it does not describe a realistic scenario about how this issue could happen.
I found the POC hard to follow. A coded instance would have tremendously helped, but what I gather is:
- fully slashed transcoder that votes will do so with 0 weight.
- any delegator that delegated their votes to this specific transcoder intending to change their vote may face an issue with sub overflow because
_handleVoteOverrides()uses the slashed transcoder’sbondedAmountinstead of the 0 weight. so this issue seems valid, although its premise is that the slashing functionality is in place.The README did not indicate that slashing was turned off, though I see it’s mentioned a couple of times in the Discord channel. Should’ve been added in the “Known caveats / limitations” section.
Hence, IMO it isn’t entirely fair to wardens if I invalidate their issue because they weren’t aware of this fact.
Leaning towards a downgrade to M because of the external requirement of the active slashing mechanism, but am open to discussion.
hickuphh3 (judge) decreased severity to Medium
Revisiting this issue, IMO it’s unreasonable to expect the sponsor to explicitly list out all the gotchas / limitations of the protocol. Some will only pop into mind through discussions with wardens, which seemed to be the case here when the slashing deprecation was mentioned a couple of times in the Discord channel.
On the flip side, the fact remains that the slashing mechanism is part of the audit scope, and was counted towards the sLOC, plus the points I raised above. There wasn’t an indication in the code that slashing had been deprecated.
It’s a difficult decision here, considering the different parties’ POV. There could be some wardens who didn’t submit issues related to slashing because of what was brought up in the Discord channel, and those that did (as one can see referenced above) because they didn’t monitor the channel.
victorges (Livepeer) mitigated:
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 slashing function does not clear the transcoder's delegate address, so the voting logic still treats them as a transcoder and uses their zero bonded amount in override calculations.
Impact
A delegator may be unable to change their vote, and the vote counting could be manipulated, but the report notes that slashing is turned off in the protocol, limiting the practical impact.
What the attacker needed
Slashing mechanism active; transcoder fully slashed; transcoder votes with zero weight; delegator attempts to override vote
The fix
The issue was mitigated by a pull request, and the report recommends clearing the transcoder's delegate address upon full slashing or preventing zero-weight votes.
How it was found
- A transcoder is fully slashed, reducing their bonded amount to zero but leaving their delegated amount unchanged.
- The slashed transcoder votes on a proposal, which is recorded with zero weight.
- A delegator who delegated to that transcoder tries to override the vote.
- The override logic subtracts the delegator's weight from the transcoder's previous vote, which had zero weight, potentially causing an underflow and reverting the transaction.
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.
In this system, people can delegate their voting power to a 'transcoder' (a node operator). If that transcoder is punished ('slashed') and loses all their own stake, they can still cast a vote, but it counts as zero. Later, when a delegator tries to change their vote, the system mistakenly subtracts the delegator's weight from other people's votes, which can cause an error and stop the delegator from voting.
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.