Platform: Code4rena
Start Date: 24/07/2023
Pot Size: $100,000 USDC
Total HM: 18
Participants: 73
Period: 7 days
Judge: alcueca
Total Solo HM: 8
Id: 267
League: ETH
Rank: 45/73
Findings: 1
Award: $44.88
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: immeas
Also found by: 0x70C9, 0xAnah, 0xArcturus, 0xComfyCat, 0xWaitress, 0xackermann, 0xkazim, 2997ms, 33audits, Arz, Aymen0909, ChrisTina, JP_Courses, John_Femi, Jorgect, Kaysoft, LosPollosHermanos, MohammedRizwan, Nyx, Rolezn, Sathish9098, Stormreckson, T1MOH, Tendency, Topmark, Udsen, Vagner, albertwh1te, ast3ros, banpaleo5, berlin-101, catellatech, cats, codetilda, cryptonue, eeshenggoh, fatherOfBlocks, hals, jamshed, jaraxxus, josephdara, kankodu, kodyvim, kutugu, lanrebayode77, mert_eren, nadin, naman1778, niki, petrichor, ravikiranweb3, said, solsaver, souilos, twcctop, wahedtalash77
44.8793 USDC - $44.88
src/core/Comptroller.sol
src/core/Governance/TemporalGovernor.sol
src/core/Oracles/ChainlinkOracle.sol
L46/62/150/161 - abi.encodePacked() should not be used with dynamic types when passing the result to a hash function such as keccak256() Use abi.encode() instead which will pad items to 32 bytes, which will prevent hash collisions (e.g. abi.encodePacked(0x123,0x456) => 0x123456 => abi.encodePacked(0x1,0x23456), but abi.encode(0x123,0x456) => 0x0...1230...456). “Unless there is a compelling reason, abi.encode should be preferred”. If there is only one argument to abi.encodePacked() it can often be cast to bytes() or bytes32() instead. If all arguments are strings and or bytes, bytes.concat() should be used instead.
L101 - It is recommended by OpenZeppelin to use a try/catch when making queries to oracles. Explanation in section "ChainLink Price Feeds": https://blog.openzeppelin.com/secure-smart-contract-guidelines-the-dangers-of-price-oracles
src/core/Oracles/ChainlinkCompositeOracle.sol
L40/41/42 - No validation is performed in the constructor and the variables are immutable, therefore they should be validated before setting the variable to != 0x.
L95 - A division is made by the input: scalingFactor, therefore it could be 0 and if it were to revert, that exception would not be handled. The recommendation is to carry out a previous validation in which scalingFactor !=0.
L59/66/113/121/144/145/194/215 - There is a commented code that does not provide a better understanding of the code, therefore it should be removed.
L180 - It is recommended by OpenZeppelin to use a try/catch when making queries to oracles. Explanation in section "ChainLink Price Feeds": https://blog.openzeppelin.com/secure-smart-contract-guidelines-the-dangers-of-price-oracles
src/core/router/WETHRouter.sol
src/core/IRModels/WhitePaperInterestRateModel.sol
src/core/IRModels/JumpRateModel.sol
src/core/Unitroller.sol
L39 - The _setPendingImplementation() function is public, but it is never used inside the contract, so it should be external.
L39/59/86/109 - Multiples nombres de funciones comienzan con _, esto podria prestar confusion, ya que se podria asumir que es una funcion internal y no lo son.
#0 - c4-judge
2023-08-12T18:18:42Z
alcueca marked the issue as grade-a
#1 - ElliotFriedman
2023-08-15T18:24:11Z
validation of all variables happens in the deployment script, and integration tests of the live system, not in the contract itself.
"L46/62/150/161 - abi.encodePacked() should not be used with dynamic types when passing the result to a hash function such as keccak256() Use abi.encode() instead which will pad items to 32 bytes, which will prevent hash collisions (e.g. abi.encodePacked(0x123,0x456) => 0x123456 => abi.encodePacked(0x1,0x23456), but abi.encode(0x123,0x456) => 0x0…1230…456). “Unless there is a compelling reason, abi.encode should be preferred”. If there is only one argument to abi.encodePacked() it can often be cast to bytes() or bytes32() instead. If all arguments are strings and or bytes, bytes.concat() should be used instead."
How is a hash collision going to happen when using encodePacked if there is only a single variable passed?