ProxyFactory can circumvent ProxyRegistry
The proxy factory's deployFor function had no access control, so anyone could create proxies directly instead of going through the registry. Such unregistered proxies could still call all functions in the vault action contract, though not the privileged ones like leveraging and emptying the vault.
*Submitted by 0xDjango*
The `deployFor()` function in `MIMOProxyFactory.sol` can be called directly instead of being called within `MIMOProxyRegistry.sol`. This results in the ability to create many MIMOProxies that are not registered within the registry. The proxies deployed directly through the factory will lack the ability to call certain actions such as leveraging and emptying the vault, but will be able to call all functions in `MIMOVaultAction.sol`.
This inconsistency doesn’t feel natural and would be remedied by adding an `onlyRegistry` modifier to the `ProxyFactory.deployFor()` function.
### Proof of Concept
`MIMOProxyFactory.deployFor()` lacking any access control:
```
function deployFor(address owner) public override returns (IMIMOProxy proxy) {
proxy = IMIMOProxy(mimoProxyBase.clone());
proxy.initialize();
// Transfer the ownership from this factory contract to the specified owner.
proxy.transferOwnership(owner);
// Mark the proxy as deployed.
_proxies[address(proxy)] = true;
// Log the proxy via en event.
emit DeployProxy(msg.sender, owner, address(proxy));
}
}
```
Example of reduced functionality: `MIMOEmptyVault.executeOperation()` checks proxy existence in the proxy registry therefore can’t be called.
```
function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata premiums,
address initiator,
bytes calldata params
) external override returns (bool) {
(address owner, uint256 vaultId, SwapData memory swapData) = abi.decode(params, (address, uint256, SwapData));
IMIMOProxy mimoProxy = IMIMOProxy(proxyRegistry.getCurrentProxy(owner));
```
### Recommended Mitigation Steps
Adding access control to ensure that the factory deployFor function is called from the proxy registry would mitigate this issue.
**[RnkSngh (Mimo) confirmed and commented](https://github.com/code-423n4/2022-08-mimo-findings/issues/123#issuecomment-1210553480):**
> We confirm this is an issue and intend to implement a fix.
**horsefacts (warden) reviewed mitigation:**
> **Status:** �
Resolved
> **Finding:** Wardens identified that proxies could be deployed directly from the `MIMOProxyFactory` without being registered with the `MIMOProxyRegistry`.
> **What changed:** The `ProxyRegistry` contract has been removed, and registration functionality is now included in `MIMOProxyFactory`.
> The [only mechanism](https://github.com/mimo-capital/2022-08-mimo/blob/4e579420ecbe3fc3e770996610e6ab66b0c8d15b/contracts/proxy/MIMOProxyFactory.sol#L47) for deploying a proxy is now to call `MIMOProxyFactory#deploy`.
> **Why it works:** Since there is only one code path to deploy a `MIMOProxy` and `MIMOProxyFactory` is the single source of truth for proxy registration, it is no longer possible to deploy an unregistered proxy as described in the finding.
---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 factory's deployFor function lacked an access-control check restricting callers to the registry contract.
Impact
An attacker could create proxies that bypass the registry, gaining access to all functions in the vault action contract, though not the privileged actions such as leveraging and emptying the vault.
What the attacker needed
Ability to call the factory contract
The fix
Access control was added so only the registry could call the factory's deploy function; later the registry was removed and registration moved into the factory, leaving a single deployment path.
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 smart contract factory is meant to create new proxy contracts on behalf of users, and a registry is meant to keep a list of the legitimate ones. Here the factory could be called by anyone, so people could make proxies that the registry never knew about. Those proxies were limited but could still reach some actions, which the reporter saw as an inconsistency worth closing.
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.