fix: Winning ticket dust griefing#657
Open
SidestreamCrunchyCarrot wants to merge 12 commits into
Open
Conversation
…mic contract addresses
fix: Winning ticket dust griefing
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## delta #657 +/- ##
===============================================
Coverage 100.00000% 100.00000%
===============================================
Files 29 29
Lines 1338 1338
Branches 225 225
===============================================
Hits 1338 1338
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note: this PR was already approved by 2 Livepeer Security Committee members inside a private security advisory.
What does this pull request do? Explain your changes. (required)
This PR fixes a vulnerability where an attacker could frontrun a transcoder's
redeemWinningTicket()call by depositing a dust amount (1 wei) into the sender's account viafundDepositAndReserveFor(). BecauseredeemWinningTicket()paid out whatever funds were available and then permanently marked the ticket as used, the transcoder would receive 1 wei instead of the full face value. The same partial-payout and ticket-burn outcome could also occur naturally when multiple tickets from the same sender were redeemed in sequence, and the combined deposit and reserve were insufficient to cover all of them.The fix enforces an all-or-nothing redemption:
redeemWinningTicket()now requires thatsender.deposit + remainingReserve >= ticket.faceValuebefore marking the ticket as used. If the sender is underfunded, the call reverts, leaving the ticket redeemable once the sender tops up.Specific updates (required)
contracts/pm/mixins/MixinTicketBrokerCore.sol: Replaced thesender.deposit > 0 || remainingReserve > 0guard inredeemWinningTicket()with a stricter check requiringdeposit + reserve >= faceValue.How did you test each of these updates (required)
src/test/TicketBrokerDustDepositGriefingPoC.solto prove both attack scenarios exist: the griefing attack (testDustDepositGriefing) and the race condition (testRaceConditionPartialPayout), described in the analysis report.src/test/TicketBrokerDustDepositGriefingFix.solto prove the fix closes both scenarios while the normal flow continues to work.test/unit/TicketBroker.jswhere the previous partial-payment behavior was under test. The amounts were adjusted to be fully funded, so the test semantics are preservedfaceValueexceeds deposit and reserve combined, and succeeds whenfaceValueequals deposit and reserve combined.Does this pull request close any open issues?
Yes, it closes https://github.com/sidestream-tech/livepeer-protocol/security/advisories/GHSA-cfpp-6gv2-r325
Checklist:
ℹ️ No relevant section in the README, but the NatSpec on
redeemWinningTicket()was updated directly in the contractyarn testpass