Sublime contest - 0xDjango's results

Democratizing credit via Web3.

General Information

Platform: Code4rena

Start Date: 29/03/2022

Pot Size: $30,000 USDC

Total HM: 6

Participants: 24

Period: 3 days

Judge: HardlyDifficult

Total Solo HM: 4

Id: 101

League: ETH

Sublime

Findings Distribution

Researcher Performance

Rank: 17/24

Findings: 2

Award: $114.74

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Awards

78.2033 USDC - $78.20

Labels

bug
QA (Quality Assurance)

External Links

Issue 1 (Low) - Missing inclusive time check

https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/LenderPool.sol#L534

_withdrawLiquidity() requires that block.timestamp > pooledCLConstants[_id].startTime but should be >= as startTime should be inclusive of the event occurring.

Issue 2 (Low) - protocolFeeCollector must be trusted

https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L915

In the event that the _borrowAsset gives control on transfer such as with an ERC777, the protocolFeeCollector is able to stop all withdrawals by throwing an error prior to the liquidity being sent to the user in the following line.

Recommendation

Ensure the penalty collector is a trusted smart contract or an EOA.

Issue #3 (Low) - Some tokens need to approve 0 first

https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L755

Some tokens (like USDT) do not work when changing the allowance from an existing non-zero allowance value. They must first be approved by zero and then the actual allowance must be approved.

Issue #4 (Low) - Comment vs code conflict

https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L769

The comment highlighted in the link seems to be copied from the depositCollateral() function above it. For the withdrawCollateral() function this does not make sense.

#0 - ritik99

2022-04-13T09:25:11Z

  1. "Missing inclusive time check": This was a design choice, does not really affect the functioning. We would suggest reducing it to (0) non-critical
  2. "protocolFeeCollector must be trusted": The fee collector will be deployed by the admin, and as stated in the assumptions, the admin is a trusted actor
  3. "Some tokens need to approve 0 first": In most cases, the allowance is immediately consumed in the subsequent transfer, thus resetting it to 0. Hence setting to 0 is not really necessary, although we'll recheck all instances

Findings Information

Awards

36.5427 USDC - $36.54

Labels

bug
G (Gas Optimization)

External Links

Optimization 1 - Unnecessary inclusion in >=

https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L988

If _amount == _totalCurrentDebt, it's unnecessary to write it to _amount.

Optimization 2 - Add amount > 0 requirement in repay()

https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L976

If you add a check require(_amount > 0), it will save a lot of unnecessary code execution within this function in the case of 0 amount payments.

Optimization 3 - Multiple instantiations of IERC20

https://github.com/sublime-finance/sublime-v1/blob/46536a6d25df4264c1b217bd3232af30355dcb95/contracts/PooledCreditLine/PooledCreditLine.sol#L915-L916

Instantiate IERC20(_borrowAsset) once and then call it multiple times.

#0 - ritik99

2022-04-12T15:20:47Z

Suggestions 2 and 3 are valid, while suggestion 1 is invalid. The correct assignment needs to be made for the right amount to be transferred

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