Open c4-submissions opened 12 months ago
raymondfam marked the issue as sufficient quality report
raymondfam marked the issue as duplicate of #97
raymondfam marked the issue as high quality report
raymondfam marked the issue as not a duplicate
raymondfam marked the issue as primary issue
gus-staderlabs marked the issue as disagree with severity
LSTs are ETH derived tokens which we have in mind it is 1e18. The USDC example used though it illustrates the issue, it is not pertinent in the context of the KelpDao. Thus we agreed internally that this is a medium to low severity issue. Medium should suffice.
manoj9april (sponsor) confirmed
fatherGoose1 changed the severity to 2 (Med Risk)
Confirming as Medium. This issue highlights the potential for miscalculation for LSTs added in the future.
fatherGoose1 marked the issue as satisfactory
fatherGoose1 marked the issue as selected for report
@fatherGoose1 : The price feeds with ETH as quote tokens (X/ETH) always have 18 decimals. It would be valid if the warden can show a not-yet-supported LST/ETH priceFeed with with a decimal count differing from 18.
The example in the issue is incorrect (USDC/USD pricefeed). The issue is purely speculative and has not yet been observed in practice, so it is appropriate to classify as QA.
I agree @thangtranth. Actually, I think this is not even a QA finding. USDC example is completely out of the box. If it will be added in the future then it should be in-scope of the future audits. This is clearly OOS. The fix will only gonna increase code complexity unnecessarily.
I completely agree with @thangtranth and @DevABDee, I would also like to add that tokens that can interact with the Kelp DAO, are first whitelisted by the team. First, there is no guarantee that new tokens will be added at all, secondly, the possibility of Chainlink deciding to add a price feed for new LST/ETH with different decimals is highly unlikely. Most importantly issues of possible future upgrades have never been accepted, otherwise saying that the protocol may add a function that transfers all funds to my address should also be considered a valid finding. In my opinion, this is NC, Low at best.
Yes I agree with other wardens. We can assign it a low severity.
This is one of the reasons I didn't submit this - I couldn't find an LST with different than 18 decimals and it would be highly unlikely that one would arise and gain enough popularity. So I agree this is QA
Thank you @thangtranth. This will be downgraded to QA despite sponsor's agreement with medium severity. After looking at Chainlink's available price feeds, I confirm that 18 decimals are the standard and it would not make sense for them to support an LST price feed with other than 18 decimals.
fatherGoose1 changed the severity to QA (Quality Assurance)
fatherGoose1 marked the issue as grade-b
fatherGoose1 marked the issue as not selected for report
Lines of code
https://github.com/code-423n4/2023-11-kelp/blob/f751d7594051c0766c7ecd1e68daeb0661e43ee3/src/LRTDepositPool.sol#L109 https://github.com/code-423n4/2023-11-kelp/blob/f751d7594051c0766c7ecd1e68daeb0661e43ee3/src/LRTOracle.sol#L71
Vulnerability details
Chainlink Price Feeds does not maintain a consistent pattern for the number of decimals in returned prices. While some feeds provide token prices with 8 decimals, others may have 18 decimals or more. However, the contracts assume that prices will always be provided with 18 decimals. This could lead to discrepancies in the amount of tokens minted to users, potentially resulting in losses for them. While the price feeds for the initially supported token
rETH
,cbETH
andstETH
does have18
decimals price feeds, but there are chances that in future new tokens are added with different decimals price feeds.Impact
Some Chainlink price feeds return prices in different decimal places, such as
8
or18
, which may not align with the token's decimal representation. For example, USDC follows 6 decimal places, but the price feeds forUSDC/USD
return prices in 8 decimal places. You can check the information using the following links:USDC/USD
: https://docs.chain.link/data-feeds/price-feeds/addresses?network=ethereum&page=1&search=usdc%2FusdSo there are good chances that the price feed for the newly added LST follows different decimal representation than the decimal representation of the LST itself.
This inconsistency can result in the amount of tokens minted to the user being less than the expected amount. The incorrect result is calculated by the following functions:
Github: 109
Github: 71
Proof of Concept
Here is a test for PoC
Link to the Original Test: Test
Outupt:
As you can see in the output, for
500e18 LST
tokens we are only receiving0.00000005 RSETH
.Tools Used
Recommended Mitigation Steps
To address the issue of inconsistent decimals in the
RSETH
minting calculation, it is recommended to do the following changes in the contracts:LRTDepositPool::getRsETHAmountToMint(...)
andLRTOracle::getRSETHPrice(...)
functions to use the price feed decimals for the asset when calculating the amount ofRSETH
to be minted.Here's an example of how the changes could be implemented:
By adding the
priceFeedDecimals
mapping and modifying the calculation, we ensure that theRSETH
amount is calculated correctly based on the decimals provided by the price feeds. This mitigates the potential issue of inconsistent decimals and ensures that users receive the correct amount ofRSETH
for their deposits.The changes also needs to be done in other functions as well that are using this data.
Assessed type
Decimal