Lack of access control in the MarketFactory.updateExtension() function.
Summary
An attacker can set himself as an extension, which is an allowed protocol-wide operator. As such, he can act on an account's behalf in all its positions and, for example, withdraw its collateral.
Vulnerability Detail
A new authorization functionality was introduced in Perennial 2.3 update to allow for signers and extensions to act on behalf of the account. Unfortunately, the updateExtension() function within the MarketFactory is missing the onlyOwner access control modifier.
File: InvariantLib.sol
78: if (
79: !updateContext.signer && // sender is relaying the account's signed intention
80:@> !updateContext.operator && // sender is operator approved for account
81: !(newOrder.isEmpty() && newOrder.collateral.gte(Fixed6Lib.ZERO)) // sender is depositing zero or more into account, without position change
82: ) revert IMarket.MarketOperatorNotAllowedError();
As can be seen, anyone without authorization can set himself as an extension and act as the operator of any account, leading to the loss of all funds.
eeyore
High
Lack of access control in the
MarketFactory.updateExtension()
function.Summary
An attacker can set himself as an
extension
, which is anallowed protocol-wide operator
. As such, he can act on an account's behalf in all its positions and, for example, withdraw its collateral.Vulnerability Detail
A new authorization functionality was introduced in Perennial 2.3 update to allow for signers and extensions to act on behalf of the account. Unfortunately, the
updateExtension()
function within theMarketFactory
is missing theonlyOwner
access control modifier.This
extensions
mapping is later used in theauthorization()
function to determine if the sender is an account operator:The
authorization()
function is used within theMarket
contract to authorize the order in the name of the account:As can be seen, anyone without authorization can set himself as an extension and act as the operator of any account, leading to the loss of all funds.
Impact
Code Snippet
https://github.com/sherlock-audit/2024-08-perennial-v2-update-3/blob/main/perennial-v2/packages/perennial/contracts/MarketFactory.sol#L100-L103 https://github.com/sherlock-audit/2024-08-perennial-v2-update-3/blob/main/perennial-v2/packages/perennial/contracts/MarketFactory.sol#L77-L88 https://github.com/sherlock-audit/2024-08-perennial-v2-update-3/blob/main/perennial-v2/packages/perennial/contracts/Market.sol#L500-L504 https://github.com/sherlock-audit/2024-08-perennial-v2-update-3/blob/main/perennial-v2/packages/perennial/contracts/libs/InvariantLib.sol#L78-L82
Tool used
Manual Review
Recommendation
Add the
onlyOwner
modifier to theMarketFactory.updateExtension()
function.