Skip to content
Business logic Audit finding Intermediate

_requireVaultCollateralized() is called at the beginning of the functions mintYieldFee() and liquidate()

The collateralization check in mintYieldFee() and liquidate() runs before the functions change state, so the vault can end up under-collateralized after they finish. An attacker could mint yield fee shares even when doing so leaves the vault under-collateralized, causing a loss of funds for depositors.

RedTiger Follow with zzzitron and wangxx2026

Originally disclosed on Code4rena

Submitted by RedTiger, also found by zzzitron and wangxx2026

The liquidate() and mintYieldFee() functions could leave the vaults under-collateralized.

Proof of Concept

_requireVaultCollateralized() is called at the beginning of mintYieldFee() and liquidate(). These two functions change the state and the vault could become under-collateralized at the end of the functions.

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

function mintYieldFee(uint256 _shares, address _recipient) external {
    _requireVaultCollateralized();
    if (_shares > _yieldFeeTotalSupply) revert YieldFeeGTAvailable(_shares, _yieldFeeTotalSupply);

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

  function mintYieldFee(uint256 _shares, address _recipient) external {
    _requireVaultCollateralized();
    if (_shares > _yieldFeeTotalSupply) revert YieldFeeGTAvailable(_shares, _yieldFeeTotalSupply);

Recommended Mitigation Steps

Call _requireVaultCollateralized() at the end of these functions instead of calling it at the beginning.

Assessed type

Invalid Validation

Picodes (judge) increased severity to High

asselstine (PoolTogether) confirmed via duplicate issue #307

Picodes (judge) commented via duplicate issue #307:

Keeping High severity as this report shows how shares could be minted; although, the vault is in fact under-collateralized leading to a loss of funds for users.

PierrickGT (PoolTogether) commented via duplicate issue #307:

The warden missed the following comment:

   * @dev - We exclude the amount of yield generated by the YieldVault, so the user can only withdraw their share of deposits.
  *      Except when the vault is under-collateralized, in this case, any unclaimed yield fee is included in the calculation.

https://github.com/GenerationSoftware/pt-v5-vault/blob/a08fe40155aa65aab202c8bda5806dd91eaa1a9a/src/Vault.sol#L1169-L1170

If the Vault ends up being under-collateralized, any yield that has not been claimed will be shared proportionally between depositors. If we use _totalShares instead of _totalSupply, we would account for Vault shares that have not been minted yet, since _yieldFeeTotalSupply keeps track of the accrued yield fee, but needs to be minted as Vault shares by calling mintYieldFee: https://github.com/GenerationSoftware/pt-v5-vault/blob/44a6c6b081db5cc5e2acc4757a3c9dbaa6f60943/src/Vault.sol#L395

I’ve added the following to test this scenario: https://github.com/GenerationSoftware/pt-v5-vault/blob/44a6c6b081db5cc5e2acc4757a3c9dbaa6f60943/test/unit/Vault/Withdraw.t.sol#L128

Picodes (judge) commented via duplicate issue #307:

@PierrickGT - I do agree with you that the mitigation of this report is incorrect. However, my understanding is that there is still an important issue here; because mintYieldFee could be called even when it would lead to an under-collateralized state.

So we could imagine a scenario where _yieldFeeTotalSupply is 4, assets in the vault are 10, and user shares are 10. Then, a call to mintYieldFee would mint 4 and would lead to a loss of funds for users, as it’d bring the vault into an under-collateralized state.

PierrickGT (PoolTogether) commented via duplicate issue #307:

@Picodes - Yes, exactly. This issue you are referring to was better explained in this issue.

PoolTogether mitigated:

Fixed check for partial collateralization. PR: https://github.com/GenerationSoftware/pt-v5-vault/pull/13

Status: Mitigation confirmed. Full details in reports from 0xStalin, dirk_y and rvierdiiev.


The original report as published on Code4rena, by RedTiger. 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

Likely the collateralization check is performed before the state-changing operations in mintYieldFee() and liquidate(), so it does not account for the under-collateralization those operations can cause.

Impact

The vault could become under-collateralized, leading to a loss of funds for users; the judge noted that shares could be minted even when this would happen.

What the attacker needed

Ability to call mintYieldFee or liquidate

The fix

The check should be moved to the end of these functions, or otherwise ensure the vault remains collateralized after the state changes; the project later mitigated with a fix for partial collateralization.

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 money for many users and should always have enough assets to cover everyone's shares. The code checked that the vault was fully backed before doing an action that creates new shares, but not after, so the action itself could leave the vault short. That means some users might not be able to withdraw everything they are owed.

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 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.