Submitted by Soosh
Important note!
I first found this bug in issue(...), but unsafe downcasting appears in many other areas of the codebase, and seem to also be exploitable but no PoC is provided due to time constraints. Either way, using some form of safe casting library to replace all occurences of unsafe downcasting will prevent all the issues. I also do not list the individual instances of unsafe downcasting as all occurences should be replaced with safe cast.
The amtRToken is a user supplied parameter in the issue(uint256 amtRToken) function
The calculated amount is unsafely downcasted into uint192.
This means that if the resulting calculation is a multiple of $2^{192}$, amtBaskets = 0
The code proceeds to the following line, where erc20s and deposits arrays will be empty since we are asking for a quote for 0. (see quote(...) in BasketHandler.sol where amounts are multiplied by zero)
This means an attacker can call issue(...) with a very high amtRToken amount that is a multiple of $2^{192}$, without depositing any amount of collateral.
The DoS issues arises because whenFinished(uint256 amtRToken) is dependent on amtRToken. With such a high value, allVestAt will be set so far in the future that it causes a permanent DoS. i.e. Issuances will never vest.
This PoC demonstrates that an attacker can call issue(...) without collateral tokens to modify allVestAt variable to an extreme value, such that all further issuances cannot be vested for all users.
Do note that the PoC is done with totalSupply() == 0 case, so we supply amtRToken as a multiple of $2^{192}$. Even if there is an existing totalSupply(), we just need to calculate a value for amtRToken >= 2^192 such that $\frac{\text{basketsNeeded} \times \text{amtRToken}}{totalSupply()} = 0$. This attack does not require totalSupply() be zero.
The amount, baskets and quantities values are also messed up, but it would not matter anyways
Under Issuance and Slow Minting tests in RToken.test.ts:
Run with:
Expect to see (only important parts shown):
Permanent DoS would be High risk considering RToken is an asset-backed currency.
A currency that is unable to issue new currency does not work as a currency
Also, I believe existing collateral cannot be redeemed due to the extreme values also used in redeem(...) function. No PoC written due to time constriant for this case but above should be enough impact.
Many other downcasting issues for this project. But using a safe casting library would prevent all the issues not going to write multiple reports for same underlying issue.
Use some safe casting library. OpenZeppelins library does not have safe casting for uint192 type. May have to find another or write your own.
0xean (judge) decreased severity to Medium and commented:
tbrent (Reserve) disagreed with severity and commented:
0xean (judge) decreased severity to Low/Non-Critical
Soosh (warden) commented:
0xean (judge) commented:
Soosh (warden) commented:
tbrent (Reserve) confirmed and commented:
0xean (judge) increased severity to Medium and commented:
tbrent (Reserve) mitigated:
Status: Mitigation confirmed. Full details in reports from HollaDieWaldfee, 0xA5DF, and AkshaySrivastav.
