levETH Cannot Be Bought
The pool lets every holder of the leveraged token redeem their whole balance, which can drive the token's total supply to zero. Once supply is zero, the price calculation reverts, so nobody can create (buy) the leveraged token again.
KupiaSec Follow with PeterSR, almurhasan and 3 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-12-plaza-finance-judging/issues/333
This issue has been acknowledged by the team but won't be fixed at this time.
Found by
KupiaSec, PeterSR, almurhasan, dobrevaleri, future, sl1
Summary
If all levETH owners sell their levETH, no one will be able to buy levETH.
Root Cause
The current implementation allows for the sale of all levETH without checking if the total supply has reached zero. This results in a scenario where the price cannot be calculated, making the contract effectively useless
https://github.com/sherlock-audit/2024-12-plaza-finance/tree/main/plaza-evm/src/Pool.sol#L405
Pool.sol
function _redeem(
...) private returns(uint256) {
...
// Burn derivative tokens
if (tokenType == TokenType.BOND) {
bondToken.burn(msg.sender, depositAmount);
} else {
405: lToken.burn(msg.sender, depositAmount);
}
Internal pre-conditions
N/A
External pre-conditions
N/A
Attack Path
N/A
PoC
When the levSupply reaches zero, the contract lacks a mechanism to calculate the price of levETH. This results in an inability for users to purchase levETH.
https://github.com/sherlock-audit/2024-12-plaza-finance/tree/main/plaza-evm/src/Pool.sol#L331-L336
Pool.sol
function getCreateAmount(
...) public pure returns(uint256) {
...
if (collateralLevel <= COLLATERAL_THRESHOLD) {
if (tokenType == TokenType.LEVERAGE && assetSupply == 0) {
331: revert ZeroLeverageSupply();
}
creationRate = (tvl * multiplier) / assetSupply;
} else if (tokenType == TokenType.LEVERAGE) {
if (assetSupply == 0) {
336: revert ZeroLeverageSupply();
}
uint256 adjustedValue = tvl - (BOND_TARGET_PRICE * bondSupply);
creationRate = (adjustedValue * PRECISION) / assetSupply;
}
return ((depositAmount * ethPrice * PRECISION) / creationRate).toBaseUnit(oracleDecimals);
}
In sherlock docs:
V. How to identify a medium issue: 2. Breaks core contract functionality, rendering the contract useless or leading to loss of funds that's relevant to the affected party.
The known issue 3.20: Missing a zero-value check for assetSupply refers to the lack of a mechanism for price calculation when the amount of levETH is zero.
The root cause of this report is the absence of a check during the redemption process.
Therefore, these two issues are not duplicates.
Impact
The functionality of the core contract is compromised, rendering the contract useless.
Mitigation
Pool.sol
function _redeem(
...) private returns(uint256) {
...
// Burn derivative tokens
if (tokenType == TokenType.BOND) {
bondToken.burn(msg.sender, depositAmount);
} else {
+ require(depositAmount < lToken.totalbalance(),"");
405: lToken.burn(msg.sender, depositAmount);
}
TestCode
https://github.com/sherlock-audit/2024-12-plaza-finance/tree/main/plaza-evm/test/Pool.t.sol#L1156 Changed lined function to following code.
function testCreateRedeemWithFees() public {
vm.startPrank(governance);
// Create a pool with 2% fee
params.fee = 20000; // 2% fee (1000000 precision)
params.feeBeneficiary = address(0x942);
// Mint and approve reserve tokens
Token rToken = Token(params.reserveToken);
rToken.mint(governance, 120 ether);
rToken.approve(address(poolFactory), 120 ether);
Pool pool = Pool(poolFactory.createPool(params, 120 ether, 3000 ether, 200 ether, "", "", "", "", false));
LeverageToken lToken = LeverageToken(pool.lToken());
lToken.transfer(user, lToken.balanceOf(governance));
vm.stopPrank();
// User creates leverage tokens
vm.startPrank(user);
console2.log("Before redeem");
pool.redeem(Pool.TokenType.LEVERAGE, lToken.balanceOf(user), 0);
console2.log(" After redeem");
console2.log("Before create");
pool.create(Pool.TokenType.LEVERAGE, 10 ether, 0);
console2.log(" After Create");
vm.stopPrank();
// Reset state
rToken.burn(user, rToken.balanceOf(user));
rToken.burn(address(pool), rToken.balanceOf(address(pool)));
}
forge test --match-test "testCreateRedeemWithFees" -vv
Result:
[FAIL: ZeroLeverageSupply()] testCreateRedeemWithFees() (gas: 2054536) Logs: Before redeem After redeem Before create
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
The redeem path burns leveraged tokens without preventing the total supply from reaching zero, while the create path divides by that supply and reverts when it is zero.
Impact
Core pool functionality is broken: once the leveraged supply hits zero, no one can buy that token, and the team has acknowledged the issue but will not fix it at this time.
What the attacker needed
Hold the entire leveraged token supply
The fix
The redemption path should be changed so the leveraged token supply can never reach zero, for example by rejecting a redemption that would burn the last tokens.
How it was found
- A user holds the entire supply of the leveraged token.
- The user redeems all of their leveraged tokens, burning them.
- The user then tries to create new leveraged tokens.
- The create call reverts with a zero-supply error.
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 pool issues two kinds of tokens: a safer bond token and a leveraged token. The price of the leveraged token is worked out by dividing by how many of those tokens exist. If holders sell every last one, that number becomes zero, the division cannot happen, and the pool refuses all new purchases.
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.