# Malicious targets can manipulate MIMOProxy permissions

MIMOProxy delegatecalls into target contracts sharing its storage layout, letting a malicious target overwrite the nested _permissions mapping and grant arbitrary envoy permissions.

- Payout: Contest reward
- Severity: medium
- Program: Mimo DeFi
- Credited: horsefacts
- Disclosed: 2022-10-17
- Write-up quality: 7/10
- Original: https://github.com/code-423n4/2022-08-mimo-findings/issues/161
- Library page: https://bugbountylibrary.com/r/c4%3A2022-08-mimo%3AM-02
- Tags: domain:web3 impact:privesc kind:contest platform:code4rena sev:medium tech:evm tech:solidity technique:source-review vuln:access-control vuln:privilege-escalation

**Target:** MIMOProxy smart contract (Solidity delegatecall proxy)
**Root cause:** MIMOProxy stores envoy permissions in an internal mapping but delegatecalls into arbitrary target contracts; a target with the same storage layout can write to the _permissions slot. Owner is re-checked after delegatecall but nested mappings cannot be feasibly verified.
**Steps:**
1. Deploy a ProxyAttacks contract with identical storage layout: `address owner; uint256 minGasReserve; mapping(address=>mapping(address=>mapping(bytes4=>bool))) _permissions;`
2. Add a function `setPermission()` (selector 0x694bf8a2) that writes `_permissions[address(1)][address(2)][0xdeadbeef] = true;`
3. As an authorized envoy, call `proxy.execute(proxyAttacks.address, "0x694bf8a2")`
4. Verify `proxy.getPermission(address(1), address(2), 0xdeadbeef)` now returns true
**How found:** Code reading of MIMOProxy: noticed permissions live in internal storage while execute delegatecalls arbitrary targets, and that the owner-change guard cannot be replicated for nested mappings.
**Exploitation:** An authorized envoy (or a user tricked into approving a malicious target) invokes execute on the malicious target; the delegatecall executes in the proxy's storage context and writes arbitrary permission entries, escalating envoys/targets/selectors beyond what the owner granted.
**Escalation:** Malicious target can grant itself or colluding envoys permissions to additional targets/selectors, expanding delegatecall reach beyond owner intent.
**Insight:** When auditing delegatecall proxies, enumerate every storage variable (including nested mappings and initializer flags) and check whether a target with a matching layout can overwrite them; owner-only re-checks leave mappings unprotected.
