-
Notifications
You must be signed in to change notification settings - Fork 6
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
The throttle may be incorrectly updated when dissolving or melting rTokens #15
Comments
dupe with #89
|
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. |
thereksfour marked the issue as duplicate of #89 |
thereksfour marked the issue as unsatisfactory: |
Hi @thereksfour , @tbrent , @akshatmittal , The following code does not mean to use the
This line simply updates the The
For example, if the current It is normal to update the current Especially, I suggested below.
A non-zero I would appreciate it if you could reconsider this issue. |
Warden described that the available amount is incorrect because useAvailable() is not called to update lastAvailable before the RToken totalSupply is changed (before calling dissolve/melt/mint, etc.).
@akshatmittal and @tbrent, Please reconsider it, I think it's valid M |
This is still incorrect @thereksfour. The throttle limits what you can do in the future, not in any sliding window or the past. The behaviour is correct at the moment. |
Thank you for your comments. I understand that you believe this behavior is intentional. Suppose the current
The If this behavior had been listed as a known issue, we would accept it. |
Are you simply talking about the |
I am not sure that PJQA has ended or not.
No, I am not simply talking about the
This is just simple example to show that the total supply affects the throttle directly. |
Thanks for the comment @etherSky111! I clearly misunderstood your comment before, thanks for clarifying. Will come back to you once I'm able to think about this more and validate it. |
After discussions with sponsors, we think this finding is valid.
|
thereksfour removed the grade |
thereksfour changed the severity to QA (Quality Assurance) |
Lines of code
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/p1/RToken.sol#L121-L122
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/p1/RToken.sol#L387-L391
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/libraries/Throttle.sol#L80-L90
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/libraries/Throttle.sol#L69-L77
Vulnerability details
Impact
The
throttle
is designed to ensure that the netissuance
orredemption
of anRToken
does not exceed certain limits per hour.Correctly updating these values is essential to maintain the intended
issuance
andredemption
processes.The current
total supply
is crucial in calculating the available amount forissuance
andredemption
.Therefore, the
throttle
should be updated properly before thetotal supply
changes, such as duringissuance
andredemption
.However, there is an exception when dissolving
RTokens
duringrecollateralization
in theBackingManager
or meltingRTokens
.In this case, the
throttle
is not updated before thetotal supply
decreases.As a result, the
throttle
value becomes lower than it should be, potentially affecting futureissuance
andredemption
.Proof of Concept
When
issuing
orredeeming
RTokens
, the calculation of currently available amounts is crucial (line 121, 122
).The current
total supply
plays a key role in this process.Therefore, it's important to update the
throttle
before changing thetotal supply
.However, the
throttle
is not updated in thedissolve
andmelt
functions.Also the
throttle
is not updated in themint
function.Let's look at an example to understand the impact:
Suppose the current
total supply
is100
, thepctRate
is10%
, and theamtRate
is1
.The last update occurred an hour ago and the
throttle.lastAvailable
is0
.In this case, the
hourlyLimit
function would return10
.And the
currentlyAvailable
function would also return10
.Now, if the
melt
ordissolve
function is called, reducing thetotal supply
to20
, thehourlyLimit
function would then return2
, andcurrentlyAvailable
would also return2
for the nextissuance
andredemption
.This happens because we didn't update
throttle.lastAvailable
using the originaltotal supply
before it was changed.Tools Used
Recommended Mitigation Steps
Add the following lines to the
dissolve
andmelt
functions.If we consider
dissolving
andmelting
as types ofredemption
, theamount
value can reference those values.Assessed type
Error
The text was updated successfully, but these errors were encountered: