Skip to content
Business logic Audit finding Advanced

The exchange rate change in the case of Lossy Strategy will cause the Vault to be under-collateralized for generic ERC4626 Yield Vaults

For Yield Vaults that use Lossy Strategies, the PT Vault burns more Yield Vault shares than intended when processing a withdrawal, socializing a loss at the advantage of early withdrawers. An attacker could withdraw early to avoid losses, leaving other depositors to bear the loss.

GalloDaSballo Follow

Originally disclosed on Code4rena

Submitted by GalloDaSballo

For Yield Vaults that use Lossy Strategies, the PT Vault will burn more Yield Vault Shares than intended when processing a withdrawal, socializing a loss at the advantage of early withdrawers.

withdraw calls _convertToShares:

https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L517

    uint256 _shares = _convertToShares(_assets, Math.Rounding.Up);

Which uses the _currentExchangeRate(). This in turn, computes the withdrawableAssets by fetching yieldVault.maxWithdraw and then mapping the principal vs. the totalSupply.

https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L1169C1-L1187C4

    uint256 _withdrawableAssets = _yieldVault.maxWithdraw(address(this));

    if (_withdrawableAssets > _totalSupplyToAssets) {
      _withdrawableAssets = _withdrawableAssets - (_withdrawableAssets - _totalSupplyToAssets);
    }

    if (_totalSupplyAmount != 0 && _withdrawableAssets != 0) {
      return _withdrawableAssets.mulDiv(_assetUnit, _totalSupplyAmount, Math.Rounding.Down);
    }

This calculation is based on maxWithdraw, which is a view function.

Most implementations of maxWithdraw will simply map the available tokens to the shares owned by the owner. See OZ for example:

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/121be5dd09caa2f7ce731f0806b0e14761023bd6/contracts/token/ERC20/extensions/ERC4626.sol#L141-L143

    function maxWithdraw(address owner) public view virtual returns (uint256) {
        return _convertToAssets(balanceOf(owner), Math.Rounding.Floor);
    }

Or similarly, Yearn V3.

Due to the implementation, losses can be applied during YieldVault.withdraw, causing the burning of more shares than intended.

Because the PT Vault computes the shares to burn before accounting for a potential loss:

  • No loss will be accounted for in maxWithdraw (since it will use static value for assets in the vault and assets in the strategy).
  • The loss will be locked during _withdraw, but it will not be checked. The specifics of the loss are that it will cause burning of more shares in order to receive the intended assets.
  • This will cause the user to pay shares from PT Vault.
  • But it will cause PT Vault to pay more yieldVault Shares than intended, effectively diluting everyone else and socializing the losses on the laggards.

Proof Of Concept

  • Call withdraw.
  • This will compute the shares to burn to the user via _convertToShares.
  • PT Vault will call YieldVault.withdraw with the amount necessary to withdraw.
  • The Vault will take a loss. The loss will cause more shares from PT Vault to be burned, socializing a loss to other depositors.

Mitigation

Ensures that the PPFS of the Yield Vault doesn’t decrease, or add functions to handle lossy withdrawals.

Assessed type

ERC4626

asselstine (PoolTogether) confirmed

PierrickGT (PoolTogether) commented:

I don’t entirely understand the issue here; to me it looks like this is the intended behavior.

Users knowingly deposit in a Vault relying on a YieldVault that employs Lossy Strategies to generate yield. Let’s say for example, an option protocol, the position of the Vault loses value so all shares are backed by less underlying assets. When withdrawing, people will only be able to withdraw their shares of deposits, which indeed socializes the loss.

I think for this kind of YieldVaults, we will need to develop custom Vaults, because it’s a pretty specific use case.

PoolTogether mitigated:

Redeemed underlying liquidity using shares, not assets directly. This socializes losses, if any. PR: https://github.com/GenerationSoftware/pt-v5-vault/pull/27

Status: Not fully mitigated. Full details in report from dirk_y and in the Mitigation Review section below.

PierrickGT (PoolTogether) commented:

Working PR here: https://github.com/GenerationSoftware/pt-v5-vault/pull/37.


The original report as published on Code4rena, by GalloDaSballo. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 PT Vault computes shares to burn using a view function (maxWithdraw) that does not account for losses that occur during the actual withdrawal, so the exchange rate used is stale and the loss is socialized.

Impact

Early withdrawers could avoid losses while other depositors bear the loss, potentially under-collateralizing the vault.

What the attacker needed

Yield Vault uses a Lossy Strategy; User can withdraw before loss is realized

The fix

The mitigation was to redeem underlying liquidity using shares, not assets directly, which socializes losses if any, but the status is not fully mitigated.

How it was found

  1. Call withdraw.
  2. This will compute the shares to burn to the user via _convertToShares.
  3. PT Vault will call YieldVault.withdraw with the amount necessary to withdraw.
  4. The Vault will take a loss. The loss will cause more shares from PT Vault to be burned, socializing a loss to other depositors.

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 vault holds shares representing a pool of assets. When someone withdraws, the vault calculates how many shares to burn based on the current exchange rate. If the underlying strategy has lost money, the calculation is wrong and the vault burns too many shares, meaning the remaining depositors get less than they should. This lets early withdrawers avoid the loss at the expense of others.

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.

More by GalloDaSballo

View all

30 more disclosed reports, best first.

More from PoolTogether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.