Market coordinator can liquidate all users in the market
A market coordinator can set margin and maintenance ratios and fees to extreme values, making all user positions unhealthy and allowing the coordinator to liquidate them and collect fees. This can steal at least 1% from all market users.
Source: https://github.com/sherlock-audit/2024-08-perennial-v2-update-3-judging/issues/29
Found by
panprog Summary The README states the following:
Q: Please list any known issues and explicitly state the acceptable risks for each known issue. Coordinators are given broad control over the parameters of the markets they coordinate. The protocol parameter is designed to prevent situations where parameters are set to malicious steal funds. If the coordinator can operate within the bounds of reasonable protocol parameters to negatively affect markets we would like to know about it
Market coordinator can change margin and maintenance ratios and min USD amounts, and these do not have any upside limitation. This means that malicious coordinator can set these values to extremely high amounts (like 1000%), which will make all users positions unhealthy, allowing malicious coordinator to liquidate all users, negatively affecting all market users.
Since the coordinator also controls the fees, the full attack can consist of setting high margin and maintenance amounts, max fees, then liqudating all makers, opening small maker position and liquidating all takers, receiving max fee percentage off all users notional.
Root Cause It's probably not possible to avoid some users becoming liquidatable when the margin ratio is increased, even by well-intended coordinator. Still, there are neither timelock to let users know of the changes in advance, nor any sanity upside limit for the margin, the only limit is downside (so that it can't be set to 0): https://github.com/sherlock-audit/2024-08-perennial-v2-update-3/blob/main/perennial-v2/packages/perennial/contracts/types/RiskParameter.sol#L147-L157
Internal pre-conditions Malicious market coordinator.
External pre-conditions None.
Attack Path
- Coordinator sets max margin and maintenance ratios, max allowed liquidation fee and all the other fees
- Coordinator liquidates all makers
- Coordinator opens small maker position
- Coordinator liquidates all takers, which earns small liquidation fees + all position closure fees (which are percentage-based, e.g. 1%) are accumulated to coordinator's maker, which is the only maker in the market
- Coordinator closes maker position and withdraws all collateral
Impact At least 1% or more is stolen from all market users, along with all market positions being liquidated.
PoC Not needed.
Mitigation
- Force coordinator time lock, so that all users know well in advance of incoming market parameters changes
- Optionally add some sanity upside limit to margin, maintenance, minMargin and minMaintenance (set via protocolParameters).
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/equilibria-xyz/perennial-v2/pull/464
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 lack of an upper limit on margin and maintenance ratios and no timelock on parameter changes allows a malicious coordinator to set extreme values.
Impact
At least 1% or more is stolen from all market users, along with all market positions being liquidated.
What the attacker needed
Malicious market coordinator
The fix
The protocol team fixed this issue in the following PRs/commits: https://github.com/equilibria-xyz/perennial-v2/pull/464
How it was found
- Coordinator sets max margin and maintenance ratios, max allowed liquidation fee and all the other fees
- Coordinator liquidates all makers
- Coordinator opens small maker position
- Coordinator liquidates all takers, which earns small liquidation fees + all position closure fees
- Coordinator closes maker position and withdraws all collateral
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.
A market coordinator is like a manager who sets the rules for a trading market. This report shows that the manager could set the rules so strictly that everyone else's account appears to be in trouble, then the manager could take their money by liquidating them. Liquidation is when someone's position is closed because it is considered too risky.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.