CF minimum can be bypassed when minting nuAssets
The collateral factor (CF) check in the minting function runs before the mint instead of after, so a user can mint a large amount of nuAssets and push the CF below the warning threshold. This breaks the stated invariant that new synthetics cannot be minted when the theoretical CF is below 110%.
Source: https://github.com/sherlock-audit/2024-12-numa-audit-judging/issues/41
Found by
juaan
Summary
CF is checked before minting nuAssets (instead of after), allowing CF to be massively decreased past the warning. This allows assets to be minted even past the critical CF of 110%, breaking the invariant stated in the README.
NumaPrinter.mintNuAsset() has the notInWarningCF modifier
modifier notInWarningCF() {
uint currentCF = vaultManager.getGlobalCF();
require(currentCF > vaultManager.getWarningCF(), "minting forbidden");
_;
}
Invariant stated in the README is bypassed:
New synthetics cannot be minted when CFTHEORETICAL < 110%, where CFTHEORETICAL = rETH_accountingBalance / synthetic_rETHdebt.
Root Cause
The modifier checks the CF before the minting of the nuAssets.
This means that a user can mint a large number of nuAssets to effectively minting past the warning CF.
Internal pre-conditions
No response
External pre-conditions
No response
Attack Path
No response
Impact
No response
PoC
The PoC shows that the CF goes from 1e5 to 1.0527e4 during the mint, while the warning CF is 9.9999e4, so the warning CF has been bypassed, and assets have effectively been minted past the warning CF which should not be allowed.
Add the test to Printer.t.sol
function test_mintPastCF() public {
uint numaAmount = 1000001e18;
vm.startPrank(deployer);
numa.transfer(userA, numaAmount);
vm.stopPrank();
vm.startPrank(userA);
// compare getNbOfNuAssetFromNuma
(uint256 nuUSDAmount, uint fee) = moneyPrinter.getNbOfNuAssetFromNuma(
address(nuUSD),
numaAmount
);
numa.approve(address(moneyPrinter), numaAmount);
// warning cf test block mint
uint globalCFBefore = vaultManager.getGlobalCF();
// put back warning cf
vm.startPrank(deployer);
vaultManager.setScalingParameters(
vaultManager.cf_critical(),
globalCFBefore - 1,
vaultManager.cf_severe(),
vaultManager.debaseValue(),
vaultManager.rebaseValue(),
1 hours,
2 hours,
vaultManager.minimumScale(),
vaultManager.criticalDebaseMult()
);
console.log("globalCFBefore: %e", globalCFBefore);
console.log("warningCF: %e", vaultManager.getWarningCF());
vm.startPrank(userA);
// slippage ok
moneyPrinter.mintAssetFromNumaInput(
address(nuUSD),
numaAmount,
nuUSDAmount,
userA
);
uint globalCFAfter = vaultManager.getGlobalCF();
uint warningCF = vaultManager.getWarningCF();
console.log("globalCFAfter: %e", globalCFAfter);
console.log("warningCF: %e", warningCF);
assertGt(globalCFBefore, warningCF);
assertLt(globalCFAfter, warningCF);
}
Mitigation
Update the modifier in the following way:
modifier notInWarningCF() {
+ _;
uint currentCF = vaultManager.getGlobalCF();
require(currentCF > vaultManager.getWarningCF(), "minting forbidden");
- _;
}
This ensures that the CF is checked after minting the nuAssets, so it can't be bypassed.
Discussion
tibthecat
Not sure about that one. Needs to check with team. The goal is to block minting when CF has already reached WarningCF, not to prevent from reaching this warningCF. Will check with team, but my current opinion is that it's invalid.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
A user could mint nuAssets even when the global CF is below the warning threshold, potentially pushing it below the critical 110% level and breaking the protocol invariant.
What the attacker needed
Ability to call mintAssetFromNumaInput; sufficient NUMA balance
The fix
The modifier should be changed to check the CF after the minting logic runs, so the post-mint CF is validated.
How it was found
- Set the warning CF just below the current global CF.
- Call mintAssetFromNumaInput with a large NUMA amount.
- Observe the global CF after minting is below the warning CF.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A collateral factor (CF) is a ratio showing how much backing exists for minted assets. The contract was supposed to stop new minting once this ratio fell below a warning level, but it checked the ratio before doing the mint, so a large mint could still push the ratio far below the limit.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.