-
Notifications
You must be signed in to change notification settings - Fork 3
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
Throttle rate is applied incorrectly. #89
Comments
|
Going back at this. The throttle is supposed to apply to external interactions not internal ones, and the throttle works correctly in all of those cases. You can obviously see people making arguments in both directions on when should and should not the throttle apply, which bring it down to the goals of the throttle in the first place. |
Agree with sponsor, using throttle for internal operations is likely to result in incorrect workflow and introduce new issues. It is fine for throttle to be used to just restrict external operations. |
thereksfour marked the issue as unsatisfactory: |
thereksfour marked the issue as unsatisfactory: |
thereksfour changed the severity to QA (Quality Assurance) |
thereksfour marked the issue as grade-b |
Lines of code
https://github.com/code-423n4/2024-07-reserve/tree/main/contracts/p1/RToken.sol#L356-L359
https://github.com/code-423n4/2024-07-reserve/tree/main/contracts/p1/RToken.sol#L370-L375
https://github.com/code-423n4/2024-07-reserve/tree/main/contracts/p1/RToken.sol#L387-L391
Vulnerability details
Impact
Throttle rate will be applied incorrectly.
For instance, the
RToken
can be issued more than issuance throttle settings or can be redeemed less than redemption throttle settings.Proof of Concept
RToken
updates the available amount and last update time of throttle limit for issueance and redemption inissueTo
,redeemTo
andredeemCustom
functions but not update them inmint
,melt
anddissolve
functions.For instance,
mint
function doesn't issue tokens to users but increase thetotalSupply
ofRToken
.Since the calculation of available amount depends on
totalSupply
, this causes the incorrect applying of throttle rate.Vulnerability Detail
RToken
update and check the throttle in theissueTo
function as follows.Then the
totalSupply
is used inThrottle.sol#useAvailable
function as follows.totalSupply
is used to calculatelimit
inL46
and thenlimit
is used to calculateavailable
inL49
.currentlyAvailable
function ofL49
is the following.As a result, we can see that the increasement of available amount depends on
totalSupply
and the duration of it (L74-L75
).However,
mint
function increase thetotalSupply
but doesn't update theissuanceThrottle.lastTimestamp
.From this, the following scenario is available.
issuanceThrottle.params.amtRate
is zero or small, so we can ignore it.And assume that
issuanceThrottle.params.pctRate = 10%
.totalSupply
ofRToken
is1000
att = 0
.Then the hourly limit of issuance is
1000 * 10% = 100
.RToken
for an hour.t = 3599
,1000
ofRToken
is minted bybackingManager
. ThentotalSupply
is updated to2000
now.t = 3600
, A user can callsissueTo
to issueRToken
withamount = 200
.totalSupply = 1000
fromt = 0
tot = 3599
andtotalSupply = 2000
fromt = 3599
tot = 3600
, the hourly limit of issuance should be(1000 * 10% * 3599 + 2000 * 10% * 1) / 3600 = 100
.However, the user issued
200
tokens in1 hour
which exceeds100
.Tools Used
Manual Review
Recommended Mitigation Steps
Modify
RToken.sol#mint
function as follows.Assessed type
Math
The text was updated successfully, but these errors were encountered: