Submitted by horsefacts, also found by giovannidisiena and Lambda
https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/proxy/MIMOProxy.sol#L18-L19
https://github.com/code-423n4/2022-08-mimo/blob/eb1a5016b69f72bc1e4fd3600a65e908bd228f13/contracts/proxy/MIMOProxy.sol#L74-L79
The MIMOProxy contract defines a minGasReserve value as a storage variable:
MIMOProxy.sol#L18:
The execute function uses this minGasReserve value to calculate a gas stipend to provide to the target contract when executing a delegatecall:
MIMOProxy.sol#L74:
Although minGasReserve is a public storage variable, it has no corresponding setter function. There used to be one in the upstream PRBProxy, but it was removed in version 2.0. The intent of this change was to simplify the proxy contract, while allowing users to delegatecall to their own target contract to set this value if necessary.
However, a malicious target contract can permanently block access to a MIMOProxy by setting minGasReserve to a very high value and forcing an underflow in the gas stipend calculation:
MIMOProxy.sol#L75
If a target contract intentionally or accidentally sets minGasReserve to a value higher than the block gas limit, the execute function will always underflow and revert. In this scenario, it is impossible to set minGasReserve back to a reasonable value, since the change must be made through the execute function.
Impact: If a user intentionally or accidentally sets a high minGasReserve, they may permanently lose access to their MIMOProxy. Malicious target contracts may attempt to trick users into bricking their proxy contracts using this method.
Restore the setMinGasReserve function removed in PRBProxy v2.0, which will allow the proxy owner to directly set this value:
Well use this ProxyAttacks helper contract to manipulate proxy storage. Note that it has the same storage layout as MIMOProxy.
Then deploy the ProxyAttacks helper in a test environment and use MIMOProxy to delegatecall into it:
RnkSngh (Mimo) marked as duplicate:
gzeoneth (judge) commented:
horsefacts (warden) reviewed mitigation:
