Revert Lend - befree3x's results

A lending protocol specifically designed for liquidity providers on Uniswap v3.

General Information

Platform: Code4rena

Start Date: 04/03/2024

Pot Size: $88,500 USDC

Total HM: 31

Participants: 105

Period: 11 days

Judge: ronnyx2017

Total Solo HM: 7

Id: 342

League: ETH

Revert

Findings Distribution

Researcher Performance

Rank: 55/105

Findings: 1

Award: $92.11

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: Aymen0909

Also found by: KupiaSec, Topmark, befree3x, kennedy1030, linmiaomiao, pynschon

Labels

bug
2 (Med Risk)
satisfactory
sufficient quality report
:robot:_87_group
duplicate-324

Awards

92.1136 USDC - $92.11

External Links

Lines of code

https://github.com/code-423n4/2024-03-revert-lend/blob/435b054f9ad2404173f36f0f74a5096c894b12b7/src/V3Vault.sol#L906

Vulnerability details

[M-1] V3Vault::_deposit use a wrong condition to check for the Global Lend Limit

Vulnerability Details

In the V3Vault::_deposit function, the following condition is used to check if the total supply of the Vault does not exceed the global lend limit.


....
       if (totalSupply() > globalLendLimit) {
           revert GlobalLendLimit();
       }
....

However, globalLendLimit represents the total value that can be lent out in terms of underlying assets, while totalSupply() returns the total number of pool tokens (i.e. rTokens). As a result, this comparison is incorrect as they are not using the same unit of value.

Impact

As mentioned in the white paper, Section 2.1:

Initially, rTokens will have a 1-to-1 exchange rate with the deposited asset, but over time, as interest accrues, their value appreciates, yielding more than 1-to-1 upon redemption

As a result, there will be a difference in value between the rTokens and the underlying asset when there are more and more exchanges. This may in some cases allow a user to deposit assets even if it breaks the global lend limit safeguard.

Tools Used

Manual review.

Recommended Mitigation Steps

It's recommended to convert the total supply of shares (i.e. rTokens) back into the underlying assets, reflecting the current value of those shares within the vault before comparing it with the global lend limit.

Please consider to make the following change to the function _deposit:

....
-       if (totalSupply() > globalLendLimit) {
-           revert GlobalLendLimit();
-       }
+       if (_convertToAssets(totalSupply(), newLendExchangeRateX96, Math.Rounding.Up) >= globalLendLimit) {
+           revert GlobalLendLimit();
+       }
....

Assessed type

Invalid Validation

#0 - c4-pre-sort

2024-03-18T19:02:43Z

0xEVom marked the issue as sufficient quality report

#1 - c4-pre-sort

2024-03-18T19:03:51Z

0xEVom marked the issue as duplicate of #324

#2 - c4-judge

2024-03-31T15:35:18Z

jhsagd76 marked the issue as satisfactory

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