Skip to content
Business logic Audit finding Intermediate

Marketplace.setPrincipal do not approve needed allowance for Element vault and APWine router

The setPrincipal function in the Marketplace contract failed to grant the lender the token allowances needed for Element vault and APWine router integrations, unlike createMarket which does. As a result the lender could not operate with those tokens and the protocol integration would fail.

pashov Follow with rvierdiiev

Originally disclosed on Sherlock

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

Found by

pashov, rvierdiiev

Summary

Marketplace.setPrincipal do not approve needed allowance for Element vault and APWine router

Vulnerability Detail

Marketplace.setPrincipal is used to provide principal token for the base token and maturity when it was not set yet. To set PT you also provide protocol that this token belongs to.

In case of APWine protocol there is special block of code to handle all needed allowance. But it is not enough.

https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/Marketplace.sol#L231-L236

Solidity
        } else if (p == uint8(Principals.Apwine)) {
            address futureVault = IAPWineToken(a).futureVault();
            address interestBearingToken = IAPWineFutureVault(futureVault)
                .getIBTAddress();
            IRedeemer(redeemer).approve(interestBearingToken);
        } else if (p == uint8(Principals.Notional)) {

In Marketplace.createMarket function 2 more params are used to provide allowance of Lender for Element vault and APWine router. https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/Marketplace.sol#L182 ILender(lender).approve(u, e, a, t[7]);

But in setPrincipal we don't have such params and allowance is not set. So Lender will not be able to work with that tokens correctly.

Impact

Lender will not provide needed allowance and protocol integration will fail.

Code Snippet

Provided above.

Tool used

Manual Review

Recommendation

Add 2 more params as in createMarket and call ILender(lender).approve(u, e, a, address(0));

Discussion

sourabhmarathe

Suggested severity is Low on the grounds that we have an admin method that would allow us to handle these particular approvals. That being said, we will be implementing a fix based on this report.

Evert0x

Issue will stay medium severity, although Illuminate is able to fix it using admin powers.. it's still a broken codebase that can potentially impact user funds.

The original report as published on Sherlock, by pashov. 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 setPrincipal function was written without the extra allowance parameters that createMarket uses, so the lender approval call for Element vault and APWine router was never made.

Impact

The lender would not hold the needed allowance, so the Element vault and APWine router integrations would fail; the team noted an admin method could still set the approvals manually.

What the attacker needed

Principal token not yet set for a market; APWine or Element integration in use

The fix

The report recommends adding the two extra parameters as in createMarket and calling the lender approve function with a zero address; the team said a fix would be implemented.

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 smart contract often lets another contract spend its tokens, and that permission is called an allowance. Here one setup function forgot to give that permission for two integrations, so the lending part could not move the tokens it needed. The team could still repair it by hand with an admin action, but the code itself was broken.

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 pashov

View all

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