The RAACMinter contract is responsible for managing the minting and distribution of RAAC tokens within the RAAC lending protocol. A critical vulnerability exists in the tick()
function, where the emission rate is updated before calculating the amount to mint. This leads to incorrect minting amounts being applied to past blocks, resulting in potential discrepancies in token distribution and user rewards.
The vulnerability is located in the tick()
function of the RAACMinter contract:
Incorrect Order of Operations: The tick()
function first checks if the emission rate needs to be updated and performs that update before calculating the amount to mint. This means that the new emission rate is applied to all blocks since the last update, which is incorrect.
Minting Amount Calculation: The line uint256 amountToMint = emissionRate * blocksSinceLastUpdate;
calculates the minting amount based on the potentially updated emission rate, leading to incorrect token amounts being minted for past blocks.
Description: When the emission rate is updated before calculating the minting amount, the tokens minted do not accurately reflect the intended rewards based on the previous emission rate.
Effect: This can lead to either over-minting or under-minting of tokens, which disrupts the intended economic model of the RAAC lending protocol.
Description: Users expect their rewards to be calculated based on the emission rate at the time of their participation. If the minting amount is incorrect, users may receive more or fewer tokens than they are entitled to.
Effect: This can lead to user dissatisfaction, loss of trust in the protocol, and potential financial losses for users.
excessTokens
TrackingDescription: The excessTokens
variable is intended to track the amount of tokens available for distribution. If the minting amounts are incorrect, this variable will not accurately reflect the available tokens.
Effect: This can lead to further complications in future reward distributions, as the contract may not have a clear understanding of how many tokens are available for minting.
Description: Users rely on the protocol to manage their rewards accurately. If they experience inconsistencies in their rewards, it can lead to frustration and a lack of confidence in the system.
Effect: This can result in decreased user engagement and potential loss of users, ultimately affecting the protocol's success.
Solidity: The programming language used to implement the RAACMinter and RAACToken contracts.
OpenZeppelin Contracts: Utilized for secure implementations of ERC20 and Ownable functionalities.
Forge: A testing framework used to write and execute tests for the RAACMinter contract, including vulnerability tests.
tick()
Action: Update the tick()
function to calculate the minting amount using the current emission rate first, and then update the emission rate if needed. The corrected code should look like this:
Action: Develop additional tests to cover edge cases related to token minting and distribution. Ensure that the tests verify the correct balance of the RAACMinter after minting and that users can successfully claim their rewards based on the correct emission rate.
Action: Schedule regular security audits of the RAACMinter and RAACToken contracts to identify and address potential vulnerabilities proactively.
Action: Communicate with users about the issue and the steps being taken to resolve it. Transparency can help maintain user trust during the resolution process.
By addressing this vulnerability, the RAACMinter contract can ensure proper token management and distribution, enhancing the overall functionality and user experience of the RAAC lending protocol.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.