Omniscia Rari Capital Audit

CEtherDelegator Manual Review Findings

CEtherDelegator Manual Review Findings

CON-01M: Potentially Misbehaving Delegation

Description:

The codebase of Compound explicitly lists the function signatures that are meant to be relayed via the delegatecall opcode and which are meant to be relayed via the staticcall opcode, however, the Rari implementation relays all calls utilizing delegatecall regardless.

Example:

contracts/CEtherDelegator.sol
107function () external payable {
108 // delegate all other functions to current implementation
109 (bool success, ) = implementation.delegatecall(msg.data);
110
111 assembly {
112 let free_mem_ptr := mload(0x40)
113 returndatacopy(free_mem_ptr, 0, returndatasize)
114
115 switch success
116 case 0 { revert(free_mem_ptr, returndatasize) }
117 default { return(free_mem_ptr, returndatasize) }
118 }
119}

Recommendation:

We advise that a similar paradigm to the original codebase is adopted as the absence of staticcall for certain functions enables them to conduct state changes be it internal or external.

Alleviation:

The Rari team stated that no function is meant to prohibit state changes via low-level opcodes as the underlying implementation may desire to do so; however, we still believe this to be a sensible pattern and one that can result in lower gas costs overall for the system if intensive view-only functions are utilized by other contracts of the system frequently.