Omniscia Rari Capital Audit
CErc20Delegator Manual Review Findings
CErc20Delegator Manual Review Findings
CON-01M: Potentially Misbehaving Adjustment
Type | Severity | Location |
---|---|---|
Language Specific | Minor | CErc20Delegator.sol:L106-L124 |
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:
106/**107 * @notice Delegates execution to an implementation contract108 * @dev It returns to the external caller whatever the implementation returns or forwards reverts109 */110function () external payable {111 require(msg.value == 0,"CErc20Delegator:fallback: cannot send value to fallback");112113 // delegate all other functions to current implementation114 (bool success, ) = implementation.delegatecall(msg.data);115116 assembly {117 let free_mem_ptr := mload(0x40)118 returndatacopy(free_mem_ptr, 0, returndatasize)119120 switch success121 case 0 { revert(free_mem_ptr, returndatasize) }122 default { return(free_mem_ptr, returndatasize) }123 }124}
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.