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: 44/127
Findings: 3
Award: $58.23
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: trustindistrust
Also found by: 0xbepresent, Jujic, Lambda, RaoulSchaffranek, c7e7eff, catchup, codexploder, cryptonue, d3e4, eierina, jwood, pashov, peanuts, pedroais, simon135
33.634 USDC - $33.63
https://github.com/code-423n4/2022-10-inverse/blob/main/src/Market.sol#L149
If the Governance set _collateralFactorBps as 0 while calling setCollateralFactorBps function then User full collateral will be gone as shown in POC
function setCollateralFactorBps(uint _collateralFactorBps) public onlyGov { require(_collateralFactorBps < 10000, "Invalid collateral factor"); collateralFactorBps = _collateralFactorBps; }
function getCreditLimit(address user) public view returns (uint) { uint collateralValue = getCollateralValue(user); return collateralValue * collateralFactorBps / 10000; }
Add a minimum value for _collateralFactorBps
#0 - c4-judge
2022-11-06T14:54:14Z
0xean marked the issue as duplicate
#1 - Simon-Busch
2022-12-05T15:35:31Z
Issue marked as satisfactory as requested by 0xean
#2 - c4-judge
2022-12-07T08:22:05Z
Simon-Busch marked the issue as duplicate of #301
🌟 Selected for report: adriro
Also found by: 8olidity, BClabs, CertoraInc, Chom, Franfran, Lambda, RaoulSchaffranek, Ruhum, codexploder, cryptphi, eierina, joestakey, kaden, neumo, pashov, rvierdiiev, sorrynotsorry
24.2165 USDC - $24.22
https://github.com/code-423n4/2022-10-inverse/blob/main/src/Oracle.sol#L87
Decimal normalization is done incorrectly. From code it seems that tokens are to be normalized to 18 decimal places.
uint price = feeds[token].feed.latestAnswer(); require(price > 0, "Invalid feed price"); // normalize price uint8 feedDecimals = feeds[token].feed.decimals(); uint8 tokenDecimals = feeds[token].tokenDecimals; uint8 decimals = 36 - feedDecimals - tokenDecimals; uint normalizedPrice = price * (10 ** decimals);
Decimal returned by feedDecimals and tokenDecimals could be more than 18, say 20 which means decimals = 36 - 20-20 = underflow.
Only feedDecimals consideration (feeds[token].feed.decimals()) should be enough since price is derived from feed (feeds[token].feed.latestAnswer())
Revise the normalizedPrice calculation as below:
uint8 feedDecimals = feeds[token].feed.decimals(); uint8 decimals; uint normalizedPrice; if(feedDecimals >18){ decimals = feedDecimals - 18; normalizedPrice = price / (10 ** decimals); } else { decimals = 18 - feedDecimals; normalizedPrice = price * (10 ** decimals); }
#0 - c4-judge
2022-11-05T19:53:29Z
0xean marked the issue as duplicate
#1 - c4-judge
2022-11-28T16:07:48Z
0xean marked the issue as not a duplicate
#2 - c4-judge
2022-11-28T16:07:56Z
0xean marked the issue as duplicate of #540
#3 - Simon-Busch
2022-12-05T15:32:56Z
Issue marked as satisfactory as requested by 0xean
#4 - c4-judge
2022-12-07T08:18:20Z
Simon-Busch marked the issue as duplicate of #533
🌟 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#L116 https://github.com/code-423n4/2022-10-inverse/blob/main/src/Oracle.sol#L82
The latestAnswer function has been deprecated , in favor of latestRoundData function. latestAnswer method will return the last value, but you won't be able to check if the data is fresh. On the other hand, calling the method latestRoundData allow you to run some extra validations like the round to which price belongs
uint price = feeds[token].feed.latestAnswer();
Make use of latestRoundData function instead and make basic validations
(uint80 roundID ,price,, uint256 timestamp, uint80 answeredInRound) = feeds[token].feed.latestAnswer(); require(answer > 0, "Chainlink price <= 0"); require(answeredInRound >= roundID, "Stale price"); require(timestamp != 0, "Round not complete");
#0 - neumoxx
2022-10-31T08:48:04Z
Duplicate of #601
#1 - c4-judge
2022-11-05T17:55:16Z
0xean marked the issue as duplicate
#2 - Simon-Busch
2022-12-05T15:24:02Z
Issue marked as satisfactory as requested by 0xean
#3 - c4-judge
2022-12-07T08:14:14Z
Simon-Busch marked the issue as duplicate of #584