Closed code423n4 closed 1 year ago
dmvt marked the issue as low quality report
gas report
dmvt marked the issue as unsatisfactory: Overinflated severity
gas report
This is not a gas optimisation. It is maliciously increasing the gas cost for a user such that his call might even revert due to out of gas.
Lines of code
https://github.com/code-423n4/2023-05-juicebox/blob/9d0458282511ff269b3b35b5b082b56d5cc08663/juice-buyback/contracts/JBXBuybackDelegate.sol#L144-L171
Vulnerability details
Impact
An attacker can set
mintedAmount
andreservedRate
to0
which incurs greater gas fees when callingpayParams()
. In the worst case this might cause the transaction to revert if the gas limit was tightly set to the expected gas cost.Proof of Concept
mintedAmount
andreservedRate
are supposed to be set 1-x-1 in the call flow toJBXBuybackDelegate
, 1-x inpayParams()
and x-1 indidPay()
. However,payParams()
is not access restricted so anyone can call this with_data.amount.value: 0
and_data.reservedRate: 0
which setsmintedAmount
andreservedRate
to0
, before the intended call flow. Then the user would have to pay for two 0-x-1 assignments. Setting 0-x costs 20000 gas, compared to 5000 gas for 1-x. Thus the user would have to pay 30000 gas extra after the attacker has tampered with the mutexes. If the user has set his gas limit to just above the expected gas cost of the 1-x-1 case, then his transaction will revert.Recommended Mitigation Steps
Restrict access to
payParams()
, similarly to howdidPay()
is restricted.Assessed type
DoS