StabilizerNode.stabilize may use undistributed rewards in the overflowPool as collateral
The stabilize function calculates the collateral ratio using global collateral that includes undistributed rewards sitting in the overflow pool, so the ratio can be overstated. An attacker could not directly exploit this, but the incorrect ratio could lead to wrong price targets and destabilise the peg.
Submitted by cccz
In StabilizerNode.stabilize, globalIC.collateralRatio() is used to calculate SwingTraderEntryPrice and ActualPriceTarget, with collateralRatio indicating the ratio of the current global collateral to the malt supply.
function collateralRatio() public view returns (uint256) {
uint256 decimals = malt.decimals();
uint256 totalSupply = malt.totalSupply();
if (totalSupply == 0) {
return 0;
}
return (collateral.total * (10**decimals)) / totalSupply;
}
Global collateral includes the balance of collateral tokens in the overflowPool:
function getCollateralizedMalt() public view returns (PoolCollateral memory) {
uint256 target = maltDataLab.priceTarget(); // 是否选用 getActualPriceTarget()
uint256 unity = 10**collateralToken.decimals();
// Convert all balances to be denominated in units of Malt target price
uint256 overflowBalance = maltDataLab.rewardToMaltDecimals((collateralToken.balanceOf(
address(overflowPool)
) * unity) / target);
uint256 liquidityExtensionBalance = (collateralToken.balanceOf(
address(liquidityExtension)
) * unity) / target;
(
uint256 swingTraderMaltBalance,
uint256 swingTraderBalance
) = swingTraderManager.getTokenBalances();
swingTraderBalance = (swingTraderBalance * unity) / target;
return
PoolCollateral({
lpPool: address(stakeToken),
// Note that swingTraderBalance also includes the overflowBalance
// Therefore the total doesn't need to include overflowBalance explicitly
total: maltDataLab.rewardToMaltDecimals(
liquidityExtensionBalance + swingTraderBalance
),
In StabilizerNode.stabilize, since the undistributed rewards in the overflowPool are not distributed, this can cause the actual collateral ratio to be large and thus affect the stabilize process.
A simple example is:
impliedCollateralService.syncGlobalCollateral()is called to synchronize the latest data.- There are some gap epochs in RewardThrottle and their rewards are not distributed from the overflowPool.
- When StabilizerNode.stabilize is called, it treats the undistributed rewards in the overflowPool as collateral, thus making
globalIC.collateralRatio()large, and the results of maltDataLab. getActualPriceTarget/getSwingTraderEntryPrice will be incorrect, thus making stabilize incorrect.
Since stabilize is a core function of the protocol, stabilizing with the wrong data is likely to cause malt to be depegged, so the vulnerability should be High risk.
Proof of Concept
Recommended Mitigation Steps
Call RewardThrottle.checkRewardUnderflow at the beginning of StabilizerNode.stabilize to distribute the rewards in the overflowPool, then call impliedCollateralService.syncGlobalCollateral() to synchronize the latest data.
function stabilize() external nonReentrant onlyEOA onlyActive whenNotPaused {
// Ensure data consistency
maltDataLab.trackPool();
// Finalize auction if possible before potentially starting a new one
auction.checkAuctionFinalization();
+ RewardThrottle.checkRewardUnderflow();
+ impliedCollateralService.syncGlobalCollateral();
require(
block.timestamp >= stabilizeWindowEnd || _stabilityWindowOverride(),
"Can't call stabilize"
);
0xScotch (Malt) disagreed with severity and commented:
By a strict implementation of the protocol this is a bug as it would result in global collateral being slightly misreported and therefore downstream decisions being made on incorrect data. However, in practice, the chances of a big gap in epochs is very low due to the incentivization to upkeep that as well as the degree to which the global IC would be incorrect would be very small. It seems very unlikely this bug would ever lead to a depeg as stated.
Let’s say 50% of the Malt float is in staked LP and the current APR is 10%. We go for 48 epochs (24 hours) without any call to
checkRewardUnderflow. This means the global IC will be misreported by 24 hours of APR (10%).The current APR is 10% and 50% of float is staked, therefore the yearly rewards represent 5% of the total float. One day worth of that is 5% / 365 = 0.013%.
Therefore we can say that under the above stated circumstances the global IC would be misquoted by 0.02%. Seems very unlikely that discrepancy would be the cause of a depeg.
Picodes (judge) decreased severity to Medium and commented:
Downgrading to Medium as it indeed seems that the reporting error would remain low and it is unlikely that this could lead to a depeg.
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
Root cause
Likely the stabilize function reads the global collateral ratio without first distributing pending rewards from the overflow pool, so those undistributed rewards are counted as available collateral.
Impact
The misreported collateral ratio could make stabilize use incorrect price targets, but the error is small and unlikely to cause a depeg.
What the attacker needed
Some reward epochs left undistributed; stabilize is called
The fix
The stabilize function should call checkRewardUnderflow to distribute pending rewards and then sync the global collateral before using the ratio.
How it was found
- Call syncGlobalCollateral to update the global collateral data.
- Leave some reward epochs undistributed in the overflow pool.
- Call stabilize, which uses the inflated collateral ratio to compute price targets.
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.
This is a smart contract for a stablecoin called Malt. The contract checks how much collateral backs the coin before making decisions. If some rewards are waiting to be paid out but are still counted as collateral, the contract thinks there is more backing than there really is, which could make it take the wrong action.
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.