Lack of Slippage Protection in issueTo()
functions of the RToken
contract
#122
Labels
2 (Med Risk)
Assets not at direct risk, but function/availability of the protocol could be impacted or leak value
bug
Something isn't working
🤖_primary
AI based primary recommendation
🤖_48_group
AI based duplicate group recommendation
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-07-reserve/blob/main/contracts/p1/RToken.sol#L105-L155
Vulnerability details
Impact
The
issueTo()
function lacks the slippage control that allows the users to revert if the amount of the underlying tokens they deposits is bigger than the amount they expected. Therefore, Assets for the affected users may be lose.Proof of Concept
During issuance, the user deposits the underlying tokens into the
RToken
contract, and theRToken
contract uses theissueTo()
function to issue RToken to the user.As you can see, slippage control is not implemented in the
issueTo()
function.However, slippage can occur in the
issueTo()
function due to various reasons.Calculation of the BU change based on
totalSupply()
andbasketsNeeded
The BU change is calculated as follows:
However,
totalSupply()
andbasketsNeeded
can increase or decrease at any time depending on the current on-chain conditions when the transaction is executed.Calculating
deposits[]
based oncoll.refPerTok()
The
issueTo()
function calculatesdeposits[]
using thebasketHandler.quote()
function based on the calculated BU change in #L139.The
quote()
function determinesdeposits[]
based oncoll.refPerTok()
.coll.refPerTok()
It depends on the token, but it can also increase or decrease at any time depending on the current on-chain conditions when the transaction is executed.In summary, the
issueTo()
function lacks the slippage control that allows the users to revert if the amount of the underlying tokens they deposits is bigger than the amount they expected.To prevent this, the
redeemCustom()
function implements slippage control as follows.Considering this, I think this issue could be a valid medium.
Tools Used
Manual Review
Recommended Mitigation Steps
Implement a slippage control that allows the users to revert if the amount of the underlying tokens they deposits is bigger than the amount they expected.
Assessed type
MEV
The text was updated successfully, but these errors were encountered: