Skip to content
Business logic Audit finding Intermediate

syncFeeCheckpoint() does not modify the highWaterMark correctly, sometimes it might even decrease its value, resulting in charging more performance fees than it should

The syncFeeCheckpoint modifier unconditionally overwrote the highWaterMark with the current share value, which could lower it below its previous level. This caused performance fees to be charged on gains that had already been accounted for, overcharging investors.

chaduke Follow with KIntern_NA, rbserver and 2 others

Originally disclosed on Code4rena

Submitted by chaduke, also found by KIntern_NA, rbserver, cccz, and cccz

syncFeeCheckpoint() does not modify the highWaterMark correctly, sometimes it might even decrease its value, resulting in charging more performance fees than it should.

Proof of Concept

The Vault.syncFeeCheckpoint() function does not modify the highWaterMark correctly, sometimes it might even decrease its value, resulting in charging more performance fees than it should. Instead of updating with a higher share values, it might actually decrease the value of highWaterMark. As a result, more performance fees might be charged since the highWaterMark was brought down again and again.

https://github.com/code-423n4/2023-01-popcorn/blob/d95fc31449c260901811196d617366d6352258cd/src/vault/Vault.sol# L496-L499

 modifier syncFeeCheckpoint() {
        _;
        highWaterMark = convertToAssets(1e18);
    }
  1. Suppose the current highWaterMark = 2 * e18 and convertToAssets(1e18) = 1.5 * e18.
  2. After deposit() is called, since the deposit() function has the synFeeCheckpoint modifier, the highWaterMark will be incorrectly reset to 1.5 * e18.
  3. Suppose after some activities, convertToAssets(1e18) = 1.99 * e18.
  4. TakeFees() is called, then the performance fee will be charged, since it wrongly decides convertToAssets(1e18) > highWaterMark with the wrong highWaterMark = 1.5 * e18. The correct highWaterMark should be 2 * e18:
 modifier takeFees() {
        uint256 managementFee = accruedManagementFee();
        uint256 totalFee = managementFee + accruedPerformanceFee();
        uint256 currentAssets = totalAssets();
        uint256 shareValue = convertToAssets(1e18);

        if (shareValue > highWaterMark) highWaterMark = shareValue;

        if (managementFee > 0) feesUpdatedAt = block.timestamp;

        if (totalFee > 0 && currentAssets > 0)
            _mint(feeRecipient, convertToShares(totalFee));

        _;
    }
function accruedPerformanceFee() public view returns (uint256) {
        uint256 highWaterMark_ = highWaterMark;
        uint256 shareValue = convertToAssets(1e18);
        uint256 performanceFee = fees.performance;

        return
            performanceFee > 0 && shareValue > highWaterMark
                ? performanceFee.mulDiv(
                    (shareValue - highWaterMark) * totalSupply(),
                    1e36,
                    Math.Rounding.Down
                )
                : 0;
    }
  1. As a result, the performance fee is charged when it is not supposed to do so. Investors might not be happy with this.

Tools Used

Remix

Recommended Mitigation Steps

Revise the syncFeeCheckpoint() as follows:

 modifier syncFeeCheckpoint() {
        _;

         uint256 shareValue = convertToAssets(1e18);

        if (shareValue > highWaterMark) highWaterMark = shareValue;
    }

RedVeil (Popcorn) confirmed


The original report as published on Code4rena, by chaduke. 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 syncFeeCheckpoint modifier assigned the current share value to highWaterMark without checking whether it was higher than the existing mark.

Impact

Investors could be charged more performance fees than they should, because the highWaterMark was repeatedly lowered.

What the attacker needed

A vault with performance fees enabled; share value falls below the previous highWaterMark

The fix

The modifier should only raise highWaterMark when the current share value is higher than the existing mark.

How it was found

  1. Start with a highWaterMark of 2e18 and a current share value of 1.5e18.
  2. Call deposit(), which triggers the syncFeeCheckpoint modifier and resets highWaterMark to 1.5e18.
  3. After some activity, the share value rises to 1.99e18.
  4. Call takeFees(), which charges a performance fee because 1.99e18 exceeds the wrongly lowered highWaterMark of 1.5e18.

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 tracks a 'high water mark', the highest value a share has reached, so performance fees are only taken on new profits above that level. Here, a routine update reset that mark to whatever the current value was, even if lower, so later fees were charged on gains that had already been counted.

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 chaduke

View all

21 more disclosed reports, best first.

More from Popcorn contest

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.