Automation / management can be set for not yet existing vault
The vault owner and proxy address both return zero for a non-existent vault and a caller without a proxy, so an access control check comparing them passes. An attacker could set automation or management parameters for a vault that does not yet exist, and when the vault is later created it would have those settings, potentially with very high fees leading to loss of funds.
*Submitted by Lambda, also found by ayeslick*
[https://github.com/code-423n4/2022-08-mimo/blob/9adf46f2efc61898247c719f2f948b41d5d62bbe/contracts/actions/automated/MIMOAutoAction.sol#L33](https://github.com/code-423n4/2022-08-mimo/blob/9adf46f2efc61898247c719f2f948b41d5d62bbe/contracts/actions/automated/MIMOAutoAction.sol#L33)
[https://github.com/code-423n4/2022-08-mimo/blob/9adf46f2efc61898247c719f2f948b41d5d62bbe/contracts/actions/managed/MIMOManagedAction.sol#L35](https://github.com/code-423n4/2022-08-mimo/blob/9adf46f2efc61898247c719f2f948b41d5d62bbe/contracts/actions/managed/MIMOManagedAction.sol#L35)
### Impact & Proof Of Concept
`vaultOwner` returns zero for a non-existing `vaultId`. Similarly, `proxyRegistry.getCurrentProxy(msg.sender)` returns zero when `msg.sender` has not deployed a proxy yet. Those two facts can be combined to set automation for a vault ID that does not exist yet. When this is done by a user without a proxy, it will succeed, as both `vaultOwner` and `mimoProxy` are `address(0)`, i.e. we have `vaultOwner == mimoProxy`.
The consequences of this are quite severe. As soon as the vault is created, it will be an automated vault (with potentially very high fees). An attacker can exploit this by setting very high fees before the creation of the vault and then performing actions for the automated vault, which leads to a loss of funds for the user.
The same attack is possible for `setManagement`.
### Recommended Mitigation Steps
Do not allow setting automation parameters for non-existing vaults, i.e. check that `vaultOwner != address(0)`.
**[RayXpub (Mimo) confirmed and commented](https://github.com/code-423n4/2022-08-mimo-findings/issues/68#issuecomment-1210497317):**
> We confirm that this is a high risk issue and intend to fix this.
**horsefacts (warden) reviewed mitigation:**
> **Status:** �
Resolved after review (see finding M.H-01 in Mitigation Review section below)
> **Finding:** Wardens identified that malicious callers could configure automation and management parameters for uninitialized vaults when vault owner and proxy address were unset for a given vault ID and caller and returned `adress(0)`, which caused an access control check to unintentionally pass.
> **What changed:** `MIMOAutoAction#setAutomation` now [checks](https://github.com/mimo-capital/2022-08-mimo/blob/4e579420ecbe3fc3e770996610e6ab66b0c8d15b/contracts/actions/automated/MIMOAutoAction.sol#L34) whether the vault owner is the zero address. An [integration test](https://github.com/mimo-capital/2022-08-mimo/blob/4e579420ecbe3fc3e770996610e6ab66b0c8d15b/test/02_integration/automated/MIMOAutoActionSecurity.test.ts#L119) demonstrates that attempting to call `setAutomation` on an uninitialized vault will revert. `MIMOManagedAction#setAutomation` performs the same [check](https://github.com/mimo-capital/2022-08-mimo/blob/5a63c76ed74186d11d3adb361d3b3aacefa7795e/contracts/actions/managed/MIMOManagedAction.sol#L37), and an [integration test](https://github.com/mimo-capital/2022-08-mimo/blob/5a63c76ed74186d11d3adb361d3b3aacefa7795e/test/01_unit/managed/MIMOManagedAction.test.ts#L123) exercises it.
> **Why it works:** Since `setAutomation` now explicitly checks that the vault is initialized, configuration cannot be set for an uninitialized vault.
---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
The access control check compared two addresses that both default to zero for non-existent vaults and callers without a proxy, so the check passed unintentionally.
Impact
An attacker could set automation or management parameters for a non-existent vault, and when the vault is created it would have those settings, potentially with very high fees leading to loss of funds for the user.
What the attacker needed
Attacker has no proxy deployed; vault ID does not exist yet; victim later creates that vault
How it was found
- Call setAutomation or setManagement for a vault ID that does not exist yet, from an address without a proxy.
- The check passes because both vault owner and proxy are zero.
- Set very high fees in the automation parameters.
- When the vault is later created, it becomes an automated vault with those high fees.
- Perform actions for the automated vault to cause loss of funds for the user.
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 checks if you are allowed to change settings by comparing two addresses: the vault owner and your proxy. For a vault that does not exist yet, both addresses are zero, so the check thinks they match and lets you in. This means you can set up automation or management for a vault before it is created, and the real owner later inherits those settings, which could include very high fees that cost them money.
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.