Skip to content
Business logic Audit finding Intermediate

Lending on Swivel: protocol fees not taken when remainder of underlying is swapped in YieldPool

The Swivel lending function swaps remaining underlying tokens via YieldPool without deducting protocol fees, so fees that should be collected are lost. An attacker could use this to trade on YieldPool without paying protocol fees.

kenzo Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-10-illuminate-judging/issues/45

Found by

kenzo

Summary

The lend function for Swivel allows swapping the remainder underlying on Yield. But it does not take protocol fees on this amount.

Vulnerability Detail

When executing orders on Swivel, if the user has set e==true and there is remaining underlying, the lending function will swap these funds using YieldPool. But it does not take the protocol fees on that amount.

Impact

Some protocol fees will be lost. Users may even use this function to trade on the YieldPool without incurring protocol fees. While I think it can be rightfully said that at that point they can just straight away trade on the YieldPool without incurring fees, that can also be said about the general Illuminate/Yield lend function, which swaps on the YieldPool and does extract fees.

Code Snippet

In Swivel's lend function, if the user has set e to true, the following block will be executed. Note that no fees are extracted from the raw balance.

Solidity
                if (e) {
                    // Calculate the premium
                    uint256 premium = IERC20(u).balanceOf(address(this)) - starting;
                    // Swap the premium for Illuminate principal tokens
                    swivelLendPremium(u, m, y, premium, premiumSlippage);
                }

swivelLendPremium being:

Solidity
        // Lend remaining funds to Illuminate's Yield Space Pool
        uint256 swapped = yield(u, y, p, address(this), IMarketPlace(marketPlace).token(u, m, 0), slippageTolerance);
        // Mint the remaining tokens
        IERC5095(principalToken(u, m)).authMint(msg.sender, swapped);

And yield doesn't take protocol fees either. So the fees are lost from the premium.

Tool used

Manual Review

Recommendation

In the if(e) block of Swivel's lend, extract the protocol fee from premium.

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

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 code path for swapping the remainder via YieldPool does not call the fee extraction logic that other paths use.

Impact

Some protocol fees will be lost, and users may avoid fees by using this function to trade on YieldPool.

What the attacker needed

User sets e=true; remaining underlying after order

The fix

The protocol fee should be extracted from the premium in the if(e) block of Swivel's lend function.

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 lend money through a protocol, the protocol usually takes a small cut as a fee. Here, a specific path in the lending function skips that fee, so the protocol misses out on money it should have earned.

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 kenzo

View all

53 more disclosed reports, best first.

More from Illuminate Round 2

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.