Platform: Code4rena
Start Date: 25/10/2022
Pot Size: $50,000 USDC
Total HM: 18
Participants: 127
Period: 5 days
Judge: 0xean
Total Solo HM: 9
Id: 175
League: ETH
Rank: 70/127
Findings: 2
Award: $37.11
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: rbserver
Also found by: 0x1f8b, 0xNazgul, 0xc0ffEE, 8olidity, Aymen0909, Chom, Franfran, Jeiwan, Jujic, Lambda, M4TZ1P, Olivierdem, Rolezn, Ruhum, TomJ, Wawrdog, __141345__, bin2chen, c7e7eff, carlitox477, catchup, cccz, codexploder, cuteboiz, d3e4, dipp, djxploit, eierina, elprofesor, hansfriese, horsefacts, idkwhatimdoing, imare, immeas, joestakey, ladboy233, leosathya, martin, minhtrng, pashov, peanuts, pedroais, rokinot, rvierdiiev, saneryee, sorrynotsorry, tonisives
0.385 USDC - $0.38
https://github.com/code-423n4/2022-10-inverse/blob/main/src/Oracle.sol#L82 https://github.com/code-423n4/2022-10-inverse/blob/main/src/Oracle.sol#L116
According to Chainlink's documentation, the latestAnswer function is deprecated. This function does not error if no answer has been reached but returns 0, causing an incorrect price fed from Oracle.sol
.
Manual Review
Use the latestRoundData
function to get the price instead. Add checks on the return data with proper revert messages if the price is stale or the round is uncompleted.
#0 - neumoxx
2022-10-31T08:45:58Z
Duplicate of #601
#1 - c4-judge
2022-11-05T17:50:20Z
0xean marked the issue as duplicate
#2 - Simon-Busch
2022-12-05T15:27:07Z
Issue marked as satisfactory as requested by 0xean
#3 - c4-judge
2022-12-07T08:14:13Z
Simon-Busch marked the issue as duplicate of #584
🌟 Selected for report: 0x1f8b
Also found by: 0xNazgul, 0xSmartContract, Aymen0909, B2, Bnke0x0, Deivitto, Diana, Dinesh11G, ElKu, JC, Josiah, Rahoz, RaymondFam, ReyAdmirado, Rolezn, Waze, __141345__, adriro, aphak5010, brgltd, c3phas, c7e7eff, carlitox477, cducrest, ch0bu, chrisdior4, cryptonue, cryptostellar5, cylzxje, d3e4, delfin454000, enckrish, evmwanderer, fatherOfBlocks, gogo, hansfriese, horsefacts, immeas, leosathya, lukris02, neumo, oyc_109, pedr02b2, rbserver, robee, rotcivegaf, rvierdiiev, sakshamguruji, shark, simon135, tnevler, trustindistrust, wagmi
36.7345 USDC - $36.73
ecrecover()
Severity: Low
Context: Market.sol#L425
, Market.sol#L489
, DBR.sol#L226
Description:
The function calls the Solidity ecrecover()
function directly to verify the given signatures. However, the ecrecover()
EVM opcode allows malleable (non-unique) signatures and thus is susceptible to replay attacks.
Although a replay attack seems not possible here since the nonce is increased each time, ensuring the signatures are not malleable is considered a best practice.
Recommendation:
Use the ecrecover function from OpenZeppelin's ECDSA library for signature verification. (Ensure using a version > 4.7.3
for there was a critical bug >= 4.1.0 < 4.7.3
).
Severity: Low
Context: Market.sol#L118
, Market.sol#L124
, Market.sol#L130
, Market.sol#L136
, Market.sol#L142
, Market.sol#L149
, Market.sol#L161
, Market.sol#L172
, Market.sol#L183
, Market.sol#L194
, DBR.sol#L53
, DBR.sol#L62
, BorrowController.sol#L26
, BorrowController.sol#L32
, BorrowController.sol#L38
, Oracle.sol#L44
, Oracle.sol#L53
, Oracle.sol#L61
, Fed.sol#L48
, Fed.sol#L57
, Fed.sol#L66
, Fed.sol#L75
, SimpleERC20Escrow.sol#L36
, INVEscrow.sol#L59
, GovTokenEscrow.sol#L43
Description: Several functions update critical parameters that are missing event emission. These should be performed to ensure tracking of changes of such critical parameters.
Recommendation: Consider adding events to functions that change critical parameters.
Severity: Low
Context: Market.sol#L118
, Market.sol#L124
, Market.sol#L130
, Market.sol#L136
, Market.sol#L142
, Market.sol#L149
, Market.sol#L161
, Market.sol#L172
, Market.sol#L183
, Market.sol#L194
, DBR.sol#L53
, DBR.sol#L62
, DBR.sol#L81
, DBR.sol#L90
, DBR.sol#L99
, BorrowController.sol#L26
, BorrowController.sol#L32
, BorrowController.sol#L38
, Oracle.sol#L44
, Oracle.sol#L53
, Oracle.sol#L61
, Fed.sol#L48
, Fed.sol#L57
, Fed.sol#L66
Description: Setter functions are missing checks to validate if the new value being set is the same as the current value already set in the contract. Such checks will showcase mismatches between on-chain and off-chain states.
Recommendation: This may hinder detecting discrepancies between on-chain and off-chain states leading to flawed assumptions of on-chain state and protocol behavior.
Severity: Low
Context: Market.sol#L118
, Market.sol#L124
, Market.sol#L130
, Market.sol#L136
, Market.sol#L142
, DBR.sol#L53
, DBR.sol#L81
, DBR.sol#L90
, DBR.sol#L99
, BorrowController.sol#L26
, BorrowController.sol#L32
, BorrowController.sol#L38
, Oracle.sol#L44
, Oracle.sol#L53
, Oracle.sol#L61
, Fed.sol#L48
, Fed.sol#L66
, Fed.sol#L75
, SimpleERC20Escrow.sol#L36
, INVEscrow.sol#L59
, GovTokenEscrow.sol#L43
Description: Lack of zero-address validation on address parameters may lead to transaction reverts, waste gas, require resubmission of transactions and may even force contract redeployments in certain cases within the protocol.
Recommendation: Consider adding explicit zero-address validation on input parameters of address type.
Severity: Low
Context: SimpleERC20Escrow.sol#L25
, INVEscrow.sol#L44
, GovTokenEscrow.sol#L30
Description: None of the initialize functions emit emit init-specific events. They all however have the initializer modifier (from Initializable) so that they can be called only once. Off-chain monitoring of calls to these critical functions is not possible.
Recommendation: It is recommended to emit events in your initialization functions.
Severity: Informational
Context: Market.sol#L52
Description: Some state varaibles are missing visibility.
Recommendation: Consider adding visibility to all state variables
Severity: Informational
Context: Market.sol#L124
, Market.sol#L133
, Market.sol#L145
, Market.sol#L168
, Market.sol#L173
, Market.sol#L179
, Market.sol#L184
, Market.sol#L195
, Market.sol#L209
, Market.sol#L350
, Market.sol#L360
, Market.sol#L377
, Market.sol#L433
, Market.sol#L497
, Market.sol#L526
, Market.sol#L555
, Market.sol#L587
, Market.sol#L618
, DBR.sol#L50
, DBR.sol#L58
, DBR.sol#L116
, DBR.sol#L129
, DBR.sol#L181
, DBR.sol#L320-L321
, Oracle.sol#L12-L14
, Oracle.sol#L53
, Fed.sol#L99
, SimpleERC20Escrow.sol#L49
, INVEscrow.sol#L25
, INVEscrow.sol#L62
, GovTokenEscrow.sol#L16
, GovTokenEscrow.sol#L56
Description: Max line length must be no more than 120 but many lines are extended past this length.
Recommendation: Consider cutting down the line length below 120.
Severity Informational
Context: Market.sol#L55-L56
, Market.sol#L97
, Market.sol#L101
, Market.sol#L226
, Market.sol#L245
, Market.sol#L323
, Market.sol#L344
, Market.sol#L353
, Market.sol#L389
, Market.sol#L460
, DBR.sol#L13-L14
, DBR.sol#L21-L22
, DBR.sol#L262
, DBR.sol#L266
Description:
The linked variables do not conform to the standard naming convention of Solidity whereby functions and variable names(local and state) utilize the mixedCase
format unless variables are declared as constant
in which case they utilize the UPPER_CASE_WITH_UNDERSCORES
format. Private variables and functions should lead with an _underscore
.
Recommendation: Consider naming conventions utilized by the linked statements are adjusted to reflect the correct type of declaration according to the Solidity style guide.
Severity: Informational
Context: Market.sol#L92
, DBR.sol#L44
, BorrowController.sol#L17
, Oracle.sol#L35
, Fed.sol#L14
, Fed.sol#L131
, INVEscrow.sol#L10
, INVEscrow.sol#L17
, INVEscrow.sol#L79
, GovTokenEscrow.sol#L9
, GovTokenEscrow.sol#L66
Description: The best-practice layout for a contract should follow the following order: state variables, events, modifiers, constructor and functions. Function ordering helps readers identify which functions they can call and find constructor and fallback functions easier. Functions should be grouped according to their visibility and ordered as: constructor, receive function (if exists), fallback function (if exists), external, public, internal, private. Functions should then further be ordered with view functions coming after the non-view labeled ones.
Recommendation: Consider adopting recommended best-practice for code structure and layout.
Severity: Informational
Context: Market.sol#L51
, Market.sol#L74-L76
, Market.sol#L150
, Market.sol#L162
, Market.sol#L173
, Market.sol#L184
, Market.sol#L195
, Market.sol#L336
, Market.sol#L346
, Market.sol#L360
, Market.sol#L377
, Market.sol#L563-L564
, Market.sol#L583
, Market.sol#L595
, Market.sol#L598
, Market.sol#L606
, DBR.sol#L330
, Oracle.sol#L95
, Oracle.sol#L98
, Oracle.sol#L134
, Oracle.sol#L137
Description: There are multiple occasions where certain numbers have been hardcoded, either in variables or in the code itself. Large numbers can become hard to read.
Recommendation: Consider using underscores for number literals to improve its readability.
Severity: Informational
Context: INVEscrow.sol#L35
Description: There should never be any TODOs in the code when deploying.
Recommendation: Consider finishing the TODOs before deploying.
Severity: Informational
Context: Market.sol#L172 (setReplenismentIncentiveBps => setReplenishmentIncentiveBps)
, Market.sol#L181 (liqudation => liquidation)
, Market.sol#L578 (liquidateable => liquidatable)
, DBR.sol#L50 (oprator => operator)
, DBR.sol#L60 (replen => replenishment)
, DBR.sol#L87 (allowe => allow)
, DBR.sol#L96 (unrepayable => non-repayable)
, BorrowController.sol#L36 (addres => address)
Description: Spelling errors in comments can cause confusion to both users and developers.
Recommendation: Consider checking all misspellings to ensure they are corrected.
Severity: Informational
Context: All Contracts
Description: Some functions are missing @notice/@dev NatSpec comments for the function, @param for all/some of their parameters and @return for return values. Given that NatSpec is an important part of code documentation, this affects code comprehension, auditability and usability.
Recommendation: Consider adding in full NatSpec comments for all functions to have complete code documentation for future use.
Severity: Informational
Context: All Contracts
Description: Contracts should be deployed with the same compiler version and flags that they have been tested with thoroughly. Locking the pragma helps to ensure that contracts do not accidentally get deployed using, for example, an outdated compiler version that might introduce bugs that affect the contract system negatively.
Recommendation: Consider locking the pragma version.
Severity: Informational
Context: All Contracts
Description: Using very old versions of Solidity prevents benefits of bug fixes and newer security checks. Using the latest versions might make contracts susceptible to undiscovered compiler bugs.
Recommendation: Consider using the most recent version.
#0 - c4-judge
2022-11-07T21:24:51Z
0xean marked the issue as grade-b