-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stETH/ETH
, rETH/ETH
and cbETH/ETH
chainlink oracles has too long of heartbeat and deviation threshold which can cause loss of funds
#865
Comments
raymondfam marked the issue as sufficient quality report |
raymondfam marked the issue as duplicate of #609 |
fatherGoose1 marked the issue as unsatisfactory: |
Hey @c4-judge , Sorry but I don't agree with the decision. I have gone through the other duplicate at #609 but not satisfied with the answer. I think it's not a good idea to assume that the rate remains stable and it will never go near that deviation rate. The LST to ETH conversion rate will affect the original amount of |
fatherGoose1 marked the issue as duplicate of #584 |
fatherGoose1 marked the issue as satisfactory |
fatherGoose1 changed the severity to 3 (High Risk) |
It is not an issue that the user is minted more or less rsETH as described here. Whether it is 500 or 509 it will grant the depositor the right to withdraw the same amount as he deposited. It is simply a different conversion factor. The issue in #584 arsises when there are multiple underlying assets. Here no such argument is provided, and the scenario described here leads to no loss. |
Hey @d3e4, first of all I am aware of that there will be 3 underlying assets in the beginning. I have just given an example above for a single asset for the sake of simplicity. Secondly as you said in your issue there will be arbitrage opportunity, tell me how it would be possible. Wouldn't it be because of the price deviation? What you have shown in your issue is just little bit more detailed version of the same Issue I mentioned here. You took an example of profit from it whereas I stated loss. There is no difference here. You have given good examples of how this price deviation could be an issue and that is why your issue has been selected for the final report. |
Why then did you not mention the fact that there will be three assets? This is critical. When there is one asset there is no loss. So this is not a valid example and as such your argument demonstrates no loss. (Also, #584 is not my report) |
Even something evident must be explicitly invoked if it is to form the premise of an issue. You cannot just quote the code in retrospect and say you didn't have to mention something because it is clearly there in the code. Isn't the point of a report to point out which specific parts lead to which specific impact, and how? |
First of all read this. I didn't say that only |
You calculations show the following. |
You have stated the example in wrong way. I said if the actual price |
It seems you are thinking of the issue in #443 then? That is valid, but a different issue. But in that case it is critical to mention backrunning the price update. |
Although it doesn't make sense to again comment on the issue since rewards has been announced. I would do it one last time just to answer the question. The issue is not similar to 443 at all. In that issue he talks about getting benefits by frontrunning the price update of price oracle. First of all It's only possible when you know when exactly the price is going to change and that is the tricky part. And once it is changed there is no way to front-run it. So I don't think frontrunning is possible. What my issue is can be summarized like this:
That is all what I meant to say above. Now why I say that selected issue is similar like mine is because, in that the other auditor went with the arbitrage. That is when the actual price is low but the price feed is showing high LST prices. That mean a user can deposit more LSTs and get more Please refrain from commenting any further, while I and you may not have lot on our plates, but judges and other team members do have a lot. And posting these comments only sending them unnecessary notifications. |
I see what you mean but I think what you are missing is the distinction between a direct profit and a regular trading profit. If a profit is made because of a price increase then this is a legitimate trading profit. The only thing that must not happen with regards to how much is minted is such that one could not immediately withdraw for a profit, otherwise it is just a normal trading profit, or at least not any more exploitable than the normal market mechanics. If the price change is due to an inaccurate oracle, then this still effects everyone equally, so it is not exploitable. It does cancel out, if you also take into account the other holders who equally can choose to withdraw. But you say in regards to #443 that it would be possible to frontrun the price update only if you know exactly when it is going to happen, and that this is not possible and that such a frontrunning is impossible. This is not how frontrunning works. The mempool is continuously monitored and the transaction will be spotted before it is executed, so one can indeed know exactly when it will happen in the sense that one makes sure one's own transaction is executed just before. What you describe is only exploitable, in the sense that anyone gets an unfair advantage, if you can perform this knowing about the impending price update. The only way this can be executed is through front/backrunning, or perhaps predicting the heartbeat update. So there may be a slight distinction in that sense between your issue and #443, but they are sufficiently similar, and still distinct from #584. Again, and this is the main point, a price deviation does imply the loss you say, but it is indistinguishable from a genuine price change, and is thus fair and may be taken for the real price, except by means of an exploit like #443. |
Lines of code
https://github.com/code-423n4/2023-11-kelp/blob/f751d7594051c0766c7ecd1e68daeb0661e43ee3/src/oracles/ChainlinkPriceOracle.sol#L17
Vulnerability details
ChainlinkPriceOracle
fetches prices from the Chainlink contracts. But the price feeds in the consideration has a very long priceheartbeat
anddeviation
rate which might lead to wrong price calculation and loss of token to the user.Impact
According to the chainlink docs, following are the Price feeds info for the assets that will be used initially:
RETH / ETH
CBETH / ETH
RETH / ETH
For Info,
Heartbeat
andDeviation
are variables on which the update of the prices for price feeds depends. That mean the current price feed price will be updated for the token only if one of them is met. That means if we take the example ofRETH
here, the price feed will be update only when the market price for theRETH
fluctuates by2%
or time equal to86400s
(1 day) has passed since last price update. This could be a very problematic thing. Let's assume a following scenario:-> Let's say price feeds was updated at time
T1
and price forRETH / ETH
is [1]. And since then43200s
(half day) has passed and price has become [1.018] (up by 1.8 %).-> Now
Bob
comes and decides to deposit50 RETH
by callingLSTDepositPool::depositAsset(...)
.-> But the amount of
RSETH
token he will get is equal to:As you can see according to the market price,
9 rsETH
should be minted extra to the user. But it will not happen as the price feed deviation and heartbeat threshold hasn't passed. And that is why the prices will not be updated. Even if the checks are added in the future for staleness of price, this mechanism will not let anybody deposit token for a whole day because of staleness checks likemaxTimestamp
etc.This is one of the valid issue founded in a sherlock audit. Here is a link: Link
Proof of Concept
Calculation and Link given in the above section.
Tools Used
Recommended Mitigation Steps
It is recommended to use price feeds with less
heartbeat
anddeviation
rate. Although thedeviation
can be handled theheartbeat
is still a thing that needs to be considered. Since the time of writing this, Chainlink only support few price feeds for the above tokens with highheartbeat
anddeviation
rate. It is recommended to go for other price oracles or combine more than one together to get the average price.Assessed type
Oracle
The text was updated successfully, but these errors were encountered: