rTokenTrader#distributeTokenToBuy could be bypassed during setDistribution by purposefully providing too little gas #205
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
sufficient quality report
This report is of sufficient quality
Lines of code
https://github.com/code-423n4/2024-07-reserve/blob/3f133997e186465f4904553b0f8e86ecb7bbacbf/contracts/p1/Distributor.sol#L61-L71
Vulnerability details
Impact
Users who stand to gain more distribution after the change could prevent distribution so they gain an unfair distribution.
Proof of Concept
Distributor.sol#L61-L71
When setting/updating distribution shares, the distributor attempts to distribute all pending tokens before making any changes. This ensures that tokens are distributed fairly according to the pre-update distributions.
When using try-catch, the default gas sent is 63/64 of the transaction gas. Although distribution is set by governance proposal, anyone can carry out the final execution. The result is that an interested party could provide just little enough gas to cause the distribution to trigger a OOG error but still have enough gas to finish updating the revenue shares. After the new distribution is in place they can distribute the token and benefit unfairly.
Tools Used
Manual review
Recommended Mitigation Steps
The try-catch pattern in setDistribution and setDistributions should be updated with the pattern that reverts on OOG errors.
Assessed type
Other
The text was updated successfully, but these errors were encountered: