Sublime contest - 0x0x0x's results

Democratizing credit via Web3.

General Information

Platform: Code4rena

Start Date: 09/12/2021

Pot Size: $50,000 USDC

Total HM: 19

Participants: 21

Period: 7 days

Judge: 0xean

Total Solo HM: 14

Id: 61

League: ETH

Sublime

Findings Distribution

Researcher Performance

Rank: 4/21

Findings: 3

Award: $3,337.45

🌟 Selected for report: 3

🚀 Solo Findings: 1

Findings Information

🌟 Selected for report: 0x0x0x

Labels

bug
3 (High Risk)
sponsor confirmed

Awards

2816.7538 USDC - $2,816.75

External Links

Handle

0x0x0x

Vulnerability details

Current implementation to get the price is as follows:

(uint256 _ratioOfPrices, uint256 _decimals) = IPriceOracle(priceOracle).getLatestPrice(_borrowAsset, _collateralAsset);

https://github.com/code-423n4/2021-12-sublime/blob/9df1b7c4247f8631647c7627a8da9bdc16db8b11/contracts/CreditLine/CreditLine.sol#L1050

But it should not consult borrowToken / collateralToken, rather it should consult the inverse of this result. As a consequence, in liquidate the liquidator/lender can lose/gain funds as a result of this miscalculation.

Mitigation step

Replace it with

(uint256 _ratioOfPrices, uint256 _decimals) = IPriceOracle(priceOracle).getLatestPrice(_collateralAsset, _borrowAsset);

Findings Information

🌟 Selected for report: hyh

Also found by: 0x0x0x

Labels

bug
duplicate
2 (Med Risk)

Awards

380.2618 USDC - $380.26

External Links

Handle

0x0x0x

Vulnerability details

When _borrowAsset == address(0), the liquidator sends ethereum via transaction value (msg.value), but _borrowTokens amount is not sent to the lender. Therefore, lender losses funds.

As seen in: https://github.com/code-423n4/2021-12-sublime/blob/main/contracts/CreditLine/CreditLine.sol#L1013-L1020

Mitigation step:

Add (bool success, ) = _lender.call{value: _borrowTokens}(''); at the end of the cited code block, so that lender receives the funds. So cited code block be replaced with the following:

uint256 _borrowTokens = _borrowTokensToLiquidate(_borrowAsset, _collateralAsset, _totalCollateralTokens); if (_borrowAsset == address(0)) { uint256 _returnETH = msg.value.sub(_borrowTokens, 'Insufficient ETH to liquidate'); if (_returnETH != 0) { (bool success, ) = msg.sender.call{value: _returnETH}(''); require(success, 'Transfer fail'); } (bool success, ) = _lender.call{value: _borrowTokens}('');

#0 - ritik99

2021-12-24T15:22:59Z

Duplicate of #90

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter