Closed code423n4 closed 1 year ago
Picodes marked the issue as duplicate of #35
The severity here is overinflated to me as the report does not highlight the fact that the owner can just set back the value to solve the issue.
Picodes changed the severity to 2 (Med Risk)
Picodes marked the issue as satisfactory
Lines of code
https://github.com/code-423n4/2023-03-mute/blob/4d8b13add2907b17ac14627cfa04e0c3cc9a2bed/contracts/bonds/MuteBond.sol#L119-L123
Vulnerability details
Impact
Detailed description of the impact of this finding. When the owner calls
setMaxPayout()
to decreasemaxPayout
tonewMaxPayout
, an attacker can front-run it and deposit so thatterms[epoch].payoutTotal <= maxPayout
butterms[epoch].payoutTotal > newMaxPayout
. This will freeze deposit() and the whole protocol all together.Proof of Concept
Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.
Let's see how an attacker can front-run
setMaxPayout()
to freeze the whole protocol:1) Suppose we have
terms[epoch].payoutTotal = 899,999e18
andmaxPayout = 1,000,000e18
.2) Suppose the owner wants to call
setMaxPayout(900,000e18)
so thatmaxPayout
can be set to900,000e18
.3) An attacker front-runs the call
setMaxPayout(900,000e18)
and callsdeposit()
to deposit with a payout of2e18
. As a result, we haveterms[epoch].payoutTotal = 900,001e18
.4) Now
setMaxPayout(900,000e18)
gets executed, withmaxPayout
set to900,000e18
. As a result, we haveterms[epoch].payoutTotal = 900,001e18 > maxPayout
.5) The deposit() function will always call
maxDeposit()
, which will always fail due to an underflow:6) Epoch will never be progressed since the following block inside
deposit()
will never get executed due to failure ofdeposit()
. Besides, the condition of the if-statement will never be true.7) Due to the front-running,
deposit()
will always fail, no epoch can be progressed, the system is frozen.Tools Used
VScode
Recommended Mitigation Steps
When
maxDeposit()
is called, the newmaxPayout
will only be in effect in the next Epoch: