Malicious user can cause inflation by directly transferring to the contract, leading to subsequent users losing funds #281
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-42
satisfactory
satisfies C4 submission criteria; eligible for awards
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2023-11-kelp/blob/main/src/LRTDepositPool.sol#L119#L144
https://github.com/code-423n4/2023-11-kelp/blob/main/src/LRTOracle.sol#L52#L79
Vulnerability details
Impact
Malicious players can cause inflation by directly transferring to the contract, leading to subsequent users losing funds.
After the user transfers a specified quantity of supported assets into the contract, they receive a certain amount of rsETH。The quantity of rSETH that a user can obtain depends on two factors:
We can examine the specific calculation process in the following code from LRTOracle.sol https://github.com/code-423n4/2023-11-kelp/blob/main/src/LRTOracle.sol#L52#L79
The issue here is that users can directly front-run the contract by transferring a certain quantity of supported assets. Malicious users do not need to spend too many tokens. In the following POC, the user used 0.01 ether to carry out the attack
Proof of Concept
Please note that the error in the price calculation method contained in
depositAsset
has been addressed in my previous submission. The following is the corrected code:Assuming Alice is the Malicious user and bob is victims. Assuming the price of supported assets is 1 ether.
Let's break down the transaction process:
The following code is a comprehensive test written using Foundry:
Here goes the output
As we can see the second user bob deposit 10 ether result in only mint 999 wei rsETH.
Tools Used
FOUNDRY,VSCODE
Recommended Mitigation Steps
Calculating the asset price directly through the balanceOf method in the contract may lead to unexpected issues. I believe there should be a global storage variable to record asset prices. This storage variable should only increase when users invoke the deposit method to mint rsETH
Assessed type
Oracle
The text was updated successfully, but these errors were encountered: