Skip to content
Business logic Audit finding Intermediate

Loss of funds in PendleConnector.depositIntoMarket()

The deposit function assumed that calling skim() would return unused tokens to the contract, but skim() actually sends surplus tokens to the Pendle treasury. As a result, the contract could permanently lose the excess SY and PT tokens it supplied when minting LP tokens.

alexxander Follow

Originally disclosed on Code4rena

Submitted by alexxander

Impact

PendleConnector contracts can lose out on funds when minting LP tokens.

Proof of Concept

The PendleMarketV3.mint() function accepts as parameters uint256 netSyDesire and uint256 netPtDesired , which serve as upper bounds, where the Market will try and mint as many LP tokens as possible such that neither of the upper bound amounts are exceeded. The issue is that in PendleConnector.depositIntoMarket, the developers incorrectly assume a call to PendleMarketV3.skim() will return back any unused tokens that were sent. The skim() function sends the extra tokens to the Pendle treasury rather than the calling contract: skim().

    * @dev skim allows us to get the surplus tokens
    */
function depositIntoMarket(IPMarket market, uint256 SYamount, uint256 PTamount) external onlyManager nonReentrant {
    (IPStandardizedYield _SY, IPPrincipalToken _PT,) = IPMarket(market).readTokens();
    IERC20(address(_SY)).safeTransfer(address(market), SYamount);
    IERC20(address(_PT)).safeTransfer(address(market), PTamount);
    market.mint(address(this), SYamount, PTamount);
    market.skim();
    emit DepositIntoMarket(address(market), SYamount, PTamount);
}

Recommended Mitigation Steps

Remove the call to market.skim() and integrate with MarketMathCore.addLiquidity() to pre-calculate the used SY and PT amounts which then can be supplied to market.mint(). This will ensure no tokens are lost.

HadiEsna (NOYA) confirmed and commented:

True, needs to be fixed.

I don’t think this one is a High severity because although the use-case of skim() function is incorrectly assumed, by putting correct inputs in the SY and PT amount, the contract is not going to lose any funds.

gzeon (judge) commented:

I think this is High risk due to MEV mentioned in issue #473, even if the UI handles SY and PT amount correctly, funds can still be stolen.


The original report as published on Code4rena, by alexxander. 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 developers wrongly assumed that PendleMarketV3.skim() refunds unused tokens to the caller, when it actually forwards the surplus to the Pendle treasury.

Impact

The connector contract could lose the surplus SY and PT tokens, and the judge noted funds could still be stolen via MEV even if inputs are correct.

What the attacker needed

Manager role on the connector; market mint leaves surplus tokens

The fix

The call to skim() should be removed and the used SY and PT amounts pre-calculated with MarketMathCore.addLiquidity() before calling mint().

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.

When you add money to a liquidity pool, you often send a bit more than needed and expect the leftover to come back. Here the code sent extra tokens and called a cleanup function believing it would refund the surplus, but that function actually gives the surplus to the project's treasury instead. So the extra tokens are gone from the contract.

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 alexxander

View all

10 more disclosed reports, best first.

More from NOYA

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.