Skip to content
Business logic Audit finding Intermediate

PositionActionPendle.sol#_onWithdraw does not have slippage parameter minOut set

When a user withdraws collateral that is a Pendle token and asks for a different destination token, the contract exits the Pendle pool with the minimum output amount hard-coded to zero. An attacker or ordinary market movement could therefore let the user receive far fewer output tokens than expected.

pkqs90 Follow with ZanyBonzy and Bauchibred

Originally disclosed on Code4rena

Submitted by pkqs90, also found by ZanyBonzy and Bauchibred

When performing withdraws on PositionActionPendle and exiting Pendle pools, users may lose funds due to not setting slippage.

Bug Description

Note: This is a new issue that was introduced by the latest code diff.

The dataflow for withdrawing on PositionActionPendle is:

  1. User withdraws collateral (which is a Pendle token) from CDPVault.
  2. User performs pendle pool exit.

The issue is in step 2; since minOut is set to 0, users may receive less output tokens than expected.

    function _onWithdraw(
        address vault,
        address position,
        address dst,
        uint256 amount
    ) internal override returns (uint256) {
        uint256 collateralWithdrawn = ICDPVault(vault).withdraw(address(position), amount);
        address collateralToken = address(ICDPVault(vault).token());

        if (dst != collateralToken && dst != address(0)) {
            PoolActionParams memory poolActionParams = PoolActionParams({
                protocol: Protocol.PENDLE,
@>              minOut: 0, // @audit-bug: No slippage.
                recipient: address(this),
                args: abi.encode(
                    collateralToken,
                    collateralWithdrawn,
                    dst
                )
            });

            bytes memory exitData = _delegateCall(
                address(poolAction),
                abi.encodeWithSelector(poolAction.exit.selector, poolActionParams)
            );

            collateralWithdrawn = abi.decode(exitData, (uint256));
        }
        return collateralWithdrawn;
    }

Also note that this is similar to the 2024-07 Loopfi audit finding M-39, which also talks about slippage in ERC4626. However, this Pendle withdraw exit pool code is new, and not existant in the last audit. Thus this should be considered a new bug.

Recommended Mitigation Steps

Allow user to set a minOut parameter for withdraw functions, especially for Pendle position and ERC4626 position.

amarcu (LoopFi) confirmed


The original report as published on Code4rena, by pkqs90. 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 withdraw handler hard-codes the Pendle pool exit slippage parameter to zero instead of letting the user supply a minimum output amount.

Impact

Users may receive less output tokens than expected when exiting a Pendle pool during withdrawal.

What the attacker needed

User withdraws Pendle-token collateral; destination token differs from collateral

The fix

The withdraw functions should let the user set a minOut parameter, especially for Pendle and ERC4626 positions.

How it was found

  1. The user withdraws Pendle-token collateral from the CDPVault.
  2. The contract exits the Pendle pool to convert it to the requested destination token.
  3. The exit runs with minOut set to zero, so the returned amount is not protected.

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.

Some contracts swap one token for another when you withdraw. A 'slippage' setting says the smallest amount you will accept back, so a bad price cannot hurt you. Here that setting was left at zero, meaning any amount, even almost nothing, was accepted.

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 pkqs90

View all

25 more disclosed reports, best first.

More from LoopFi

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.