Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: medium
Valid

Excess token can not be minted as the logic in mintRewards is incorrect

Summary

The stabilityPool calls the mintRewards function whenever raacToken needs to be minted to a receiver. However, the method used to determine the mint amount is flawed, causing a DoS for stabilityPool when minting raacToken.

Vulnerability Details

The intended use of this function is unclear since it is not called from stabilityPool. Additionally, a logical issue in the function's code prevents it from working as intended.

/contracts/core/minters/RAACMinter/RAACMinter.sol:181
181: function mintRewards(address to, uint256 amount) external nonReentrant whenNotPaused {
182: if (msg.sender != address(stabilityPool)) revert OnlyStabilityPool();
183:
184: uint256 toMint = excessTokens >= amount ? 0 : amount - excessTokens;
185: excessTokens = excessTokens >= amount ? excessTokens - amount : 0;
186:
187: if (toMint > 0) {
188: raacToken.mint(address(this), toMint);
189: }
190:
191: raacToken.safeTransfer(to, amount);
192: emit RAACMinted(amount);
193: }

The code checks if excessTokens >= amount, and if true, sets toMint = 0, meaning no new tokens are minted. Instead, the code is expected to transfer raacToken owned by the minter contract. However, in reality, excessTokens does not accurately represent the raacToken balance owned by the minter contract.
The excessTokens state variable is incremented when new tokens are minted to the stabilityPool inside the tick function.

/contracts/core/minters/RAACMinter/RAACMinter.sol:259
259: function tick() external nonReentrant whenNotPaused {
260: if (emissionUpdateInterval == 0 || block.timestamp >= lastEmissionUpdateTimestamp + emissionUpdateInterval) {
261: updateEmissionRate();
262: }
263: uint256 currentBlock = block.number;
264: uint256 blocksSinceLastUpdate = currentBlock - lastUpdateBlock;
265: if (blocksSinceLastUpdate > 0) {
266: uint256 amountToMint = emissionRate * blocksSinceLastUpdate;
267:
268: if (amountToMint > 0) {
269: excessTokens += amountToMint;
270: lastUpdateBlock = currentBlock;
271: raacToken.mint(address(stabilityPool), amountToMint);
272: emit RAACMinted(amountToMint);
273: }
274: }
275: }

Here are following issues:

  • At line 271, tokens are minted to the stabilityPool, and the excessToken variable is incremented.

  • The mintRewards function verifies whether excessToken >= amount, indicating that excessToken is considered owned by the minter contract.

  • If tokens are minted directly to the minter contract, only the extra amount is minted if amount > excessToken.

  • However, the remaining tokens are not owned by the minter contract, leading to a DoS in safeTransfer.

POC

Add the following test case in RAACMinter.test.js and run with command npx hardhat test:

it.only("Should not allow Mint of raac tokens " , async function () {
const initialSupply = await raacToken.totalSupply();
await raacMinter.tick();
const newSupply = await raacToken.totalSupply();
expect(newSupply).to.be.gt(initialSupply);
await raacMinter.connect(owner).setStabilityPool(user1.address)
let excessTokens = await raacMinter.getExcessTokens();
console.log("excessTokens" , excessTokens);
await raacMinter.connect(user1).mintRewards(user1.address , excessTokens);
});

Output:

Logs :
Error: VM Exception while processing transaction: reverted with custom error 'ERC20InsufficientBalance("0xAA5c5496e2586F81d8d2d0B970eB85aB088639c2", 0, 2638888888888889)'

Impact

mintRewards Funciton will never work as expected , whenever it got integrated in stablityPool

Tools Used

Manual Review

Recommendations

Due to unclear documentation and the function not being integrated into the current stability pool version, a definitive fix cannot be provided. However, the correct approach would be to mint tokens directly to the receiver address without any checks.

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

RAACMinter wrong excessTokens accounting in tick function

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

RAACMinter wrong excessTokens accounting in tick function

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!