Rebalance amounts should be checked so that updated balances falls within thresholds
Rebalance operations in the AMO contract only check that the pool's xETH percentage is outside the allowed thresholds before acting, but never verify that the amount minted or burned brings the percentage back inside the range. A malicious or malfunctioning defender could therefore push the pool balance past the opposite threshold.
Submitted by adriro, also found by d3e4
https://github.com/code-423n4/2023-05-xeth/blob/main/src/AMO2.sol#L239 https://github.com/code-423n4/2023-05-xeth/blob/main/src/AMO2.sol#L286
Rebalance operations are allowed when the current percentage of xETH in the Curve pool is outside the defined thresholds. However, there is no check to ensure that the amount of xETH added or burned from the pool will update the percentage to be within the limits.
Rebalance actions in the AMO contract are first validated to ensure that a rebalance is indeed needed in the first place. This is implemented by calculating the percentage of xETH in the pool and comparing the result against two limits that define an acceptable range.
Rebalance up is allowed when the percentage of xETH in the Curve pool is above the REBALANCE_UP_THRESHOLD, in which case xETH is withdrawn from the pool and burned to lower the percentage. Similarly, rebalance down is allowed when the percentage falls below the REBALANCE_DOWN_THRESHOLD value, in which case xETH is minted and added to the pool, increasing the percentage.
While care is taken to ensure that these operations are indeed only allowed when the percentages are outside the defined bounds, there is no check to ensure that the amount of xETH burned or minted will update the percentage to be within the bounds.
Proof of Concept
During a rebalance operation, a malicious or improperly operating defender can exploit the opportunity to modify the pool balance in their favor, potentially exceeding the desired boundaries.
For example, if xEthPct > REBALANCE_UP_THRESHOLD is true, the preRebalanceCheck() function would allow a rebalanceUp() operation. In such a scenario, the defender could deliberately lower the percentage to below the desired REBALANCE_DOWN_THRESHOLD, potentially gaining an advantage if the account is compromised or if there is a malfunction in the bot operating off-chain.
Recommendation
Add a check to ensure that updated balances comply with the thresholds boundaries. When minting or burning xETH from the pool, the updated balance of xETH should produce a percentage that is within the accepted range.
Assessed type
Invalid Validation
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 rebalance functions validate the pre-operation state against the thresholds but omit a post-operation check that the resulting percentage stays within the accepted range.
Impact
A malicious or malfunctioning defender could move the pool's xETH percentage beyond the opposite threshold, potentially gaining an advantage if the account is compromised or the off-chain bot malfunctions.
What the attacker needed
Defender role or compromised bot; pool percentage outside thresholds
The fix
A check should be added so that after minting or burning xETH the resulting percentage falls within the accepted threshold range.
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 contract manages a pool of tokens and is supposed to keep the share of one token (xETH) inside a set range. It checks that the share is out of range before rebalancing, but not that the rebalancing actually brings it back into range. So whoever triggers the rebalance can overshoot and move the share far past 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.