Open code423n4 opened 1 year ago
Picodes marked the issue as primary issue
mattt21 marked the issue as sponsor confirmed
Picodes marked the issue as satisfactory
Picodes marked issue #9 as primary and marked this issue as a duplicate of 9
Picodes marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2023-03-mute/blob/4d8b13add2907b17ac14627cfa04e0c3cc9a2bed/contracts/bonds/MuteBond.sol#L185-L187
Vulnerability details
The
MuteBond
contract contains a feature in which after each purchase theepochStart
increases by 5% of the time passed sinceepochStart
, this (in most cases) lowers the bond's price (i.e. buyer gets less payout) for future purchases. An attacker can exploit this feature to front-run a deposit/purchase tx and lower the victim's payout. This can also happen by innocent users purchasing before the victim's tx is included in the blockchain.Another (less likely) scenario in which this can happen is when the owner changes the config in a way that lowers the price (e.g. lowering max price, extending epoch duration), if the owner tx executes while a user's
deposit()
tx is in the mempool the user would end up with less payout than intended.Side note: the term 'bond price' might be confusing since it refers to the payout the buyer gets divided by the value the buyer pays, so a higher price is actually in favor of the buyer.
Impact
User ends up buying bond for a lower payout than intended.
Proof of Concept
In the PoC below, an attacker manages to make the buyer purchase a bond at a price lower by 32% than intended.
File:
test/bonds.ts
Recommended Mitigation Steps
Add a min payout parameter so that users can specify the expected payout. The tx should revert if the actual payout is lower than expected.