Skip to content
Business logic Audit finding Intermediate

Illuminate PTs can be used to mint other Illuminate PTs

The Lender.mint() function allowed anyone to exchange Illuminate principal tokens (PTs) for newly minted Illuminate PTs, because Illuminate PTs were themselves supported as input. An attacker could repeatedly mint new Illuminate PTs without adding asset backing, inflating the total supply and diluting the redemption value of all existing Illuminate PTs to near zero.

pashov Follow with Bnke0x0, Jeiwan and 6 others

Originally disclosed on Sherlock

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

Found by

pashov, Bnke0x0, Jeiwan, IllIllI, cccz, kenzo, HonorLt, Nyx, 0x52

Summary

Attackers can inflate away all PT value by unlimited minting

Vulnerability Detail

Lender.mint() allows anyone to exchange any supported PT for an Illuminate PT, and Illuminate PTs themselves are supported PTs by the function. By minting Illuminate PTs by providing other Illuminate PTs, an attacker can increase the total supply of Illuminate PTs without the new tokens having any asset backing. Redemptions are based on shares of the total Illuminate PT supply, rather than being redemptions of one underlying for one Illuminate PT, so as the total supply grows, the value of each share decreases.

Impact

Permanent freezing of funds

An attacker is able to inflate away the value of Illuminate PTs, making redemptions worthless, which means lenders of the protocol lose all deposited principal. Since the objective of the project is to convert other projects' PTs into Illuminate PTs, PTs of all underlyings and all maturities are affected, meaning 100% of deposited/lent principal are at risk.

While the Illuminate project does have an emergency withdraw() function that would allow an admin to rescue the funds and manually distribute them if they're still in the Lender contract, an attacker can wait for Redeemer.redeem() to have been called, at which point all PTs of the maturity and underlying would be in the Redeemer contract, which has no such rescue function. Once the attack became known, it could be prevented by calling Lender.pause(u, m, 0, true) for every underlying/maturity combination. Each new maturity would also need a separate call to pause().

Code Snippet

The mint() function takes in any value for p, including Principals.Illuminate (0), and mints new Illuminate tokens back to msg.sender

Solidity
// File: src/Lender.sol : Lender.mint()   #1

270        function mint(
271            uint8 p,
272            address u,
273            uint256 m,
274            uint256 a
275        ) external unpaused(u, m, p) returns (bool) {
276            // Fetch the desired principal token
277 @>         address principal = IMarketPlace(marketPlace).token(u, m, p);
278    
279            // Transfer the users principal tokens to the lender contract
280            Safe.transferFrom(IERC20(principal), msg.sender, address(this), a);
281    
282            // Mint the tokens received from the user
283 @>         IERC5095(principalToken(u, m)).authMint(msg.sender, a);
284    
285            emit Mint(p, u, m, a);
286    
287:           return true;

https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/Lender.sol#L270-L287

The IMarketPlace.token() call does not exclude Illuminate PTs...:

Solidity
// File: src/MarketPlace.sol : MarketPlace.token()   #2

605        function token(
606            address u,
607            uint256 m,
608            uint256 p
609        ) external view returns (address) {
610 @>         return markets[u][m][p];
611:       }

https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/MarketPlace.sol#L605-L611

...and principalToken() always returns the Illuminate PT:

Solidity
// File: src/Lender.sol : Lender.principalToken()   #3

1051        function principalToken(address u, uint256 m) internal returns (address) {
1052 @>         return IMarketPlace(marketPlace).token(u, m, 0);
1053:       }

https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/Lender.sol#L1051-L1053

Redemptions of Illuminate PTs for underlyings is based on shares of each Illuminate PT's totalSupply() of the available underlying, not the expected underlying total:

Solidity
// File: src/Redeemer.sol : Redeemer.redeem()   #4

418            // Get the amount of tokens to be redeemed from the sender
419            uint256 amount = token.balanceOf(msg.sender);
420    
421            // Calculate how many tokens the user should receive
422 @>         uint256 redeemed = (amount * holdings[u][m]) / token.totalSupply();
423    
424            // Update holdings of underlying
425            holdings[u][m] = holdings[u][m] - redeemed;
426    
427            // Burn the user's principal tokens
428            token.authBurn(msg.sender, amount);
429    
430            // Transfer the original underlying token back to the user
431            Safe.transfer(IERC20(u), msg.sender, redeemed);
432:   

https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/Redeemer.sol#L418-L432

and: https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/Redeemer.sol#L464

and: https://github.com/sherlock-audit/2022-10-illuminate/blob/main/src/Redeemer.sol#L517

POC

Diff
diff --git a/test/fork/Lender.t.sol b/test/fork/Lender.t.sol
index 999aa2c..6b97001 100644
--- a/test/fork/Lender.t.sol
+++ b/test/fork/Lender.t.sol
@@ -90,7 +90,7 @@ contract LenderTest is Test {
         // Approve lender to spend the underlying
         IERC20(u).approve(address(l), 2**256 - 1);
     }
-
+/**
     function testYieldLend() public {
         // Set up the market
         deployMarket(Contracts.USDC);
@@ -452,7 +452,7 @@ contract LenderTest is Test {
             0
         );
     }
-
+/**/
     function testMint() public {
         vm.startPrank(msg.sender);
         IERC20(Contracts.ELEMENT_TOKEN).approve(address(l), startingBalance);
@@ -468,11 +468,19 @@ contract LenderTest is Test {
         l.mint(uint8(3), Contracts.USDC, maturity, startingBalance);
 
         address ipt = mp.markets(Contracts.USDC, maturity, 0);
+        IERC20(ipt).approve(address(l), type(uint256).max);
+        l.mint(uint8(0), Contracts.USDC, maturity, 100);
         assertEq(startingBalance, IERC20(ipt).balanceOf(msg.sender));
         assertEq(0, IERC20(Contracts.ELEMENT_TOKEN).balanceOf(msg.sender));
         assertEq(
             startingBalance,
             IERC20(Contracts.ELEMENT_TOKEN).balanceOf(address(l))
         );
+        // since the user's IPT balance is still `startingBalance`
+        // after minting using 100 IPTs, the lender shouldn't have
+        // any IPT balance in order to not have inflation
+        assertEq(IERC20(ipt).balanceOf(address(l)), 0,
+                "There must be no lender IPT balance in order "
+                "to not have inflation");
     }
 }
Shell
$ forge test --fork-url $RPC_URL --fork-block-number 15189976 --use solc:0.8.16 --via-ir --match-test testMint --match-contract Lender -vv
[⠃] Compiling...
No files changed, compilation skipped

Running 1 test for test/fork/Lender.t.sol:LenderTest
[FAIL. Reason: Assertion failed.] testMint() (gas: 2696409)
Logs:
  Error: There must be no lender IPT balance in order to not have inflation
  Error: a == b not satisfied [uint]
    Expected: 0
      Actual: 100

Test result: FAILED. 0 passed; 1 failed; finished in 1.64s

Failing tests:
Encountered 1 failing test in test/fork/Lender.t.sol:LenderTest
[FAIL. Reason: Assertion failed.] testMint() (gas: 2696409)

Encountered a total of 1 failing tests, 0 tests succeeded

Tool used

Manual Review

Recommendation

Do not allow Illuminate PTs to be used to mint new Illuminate PTs, by making the following change:

Diff
diff --git a/src/Lender.sol b/src/Lender.sol
index b4a0fa2..24a596a 100644
--- a/src/Lender.sol
+++ b/src/Lender.sol
@@ -273,6 +273,11 @@ contract Lender {
         uint256 m,
         uint256 a
     ) external unpaused(u, m, p) returns (bool) {
+        // Check that the principal is NOT Illuminate
+        if (p == uint8(MarketPlace.Principals.Illuminate)) {
+            revert Exception(6, 0, 0, address(0), address(0));
+        }
+
         // Fetch the desired principal token
         address principal = IMarketPlace(marketPlace).token(u, m, p);
 

Alternatively, have the Lender burn the original PT if it's an Illuminate PT, before minting the new one

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 mint function did not exclude Illuminate PTs from being used as the input principal token, allowing recursive minting without new collateral.

Impact

An attacker could inflate away the value of all Illuminate PTs, making redemptions worthless and causing lenders to lose all deposited principal; the text notes that an admin could rescue funds still in the Lender contract via an emergency withdraw, but not once they have moved to the Redeemer contract, and the attack could be prevented by pausing each underlying/maturity combination.

What the attacker needed

Some Illuminate PTs to start with; ability to call Lender.mint()

The fix

The mint function should reject Illuminate PTs as the input principal token, or alternatively burn the original Illuminate PT before minting a new one.

How it was found

  1. Obtain some Illuminate PTs (for example by minting them from another supported PT).
  2. Approve the Lender contract to spend the Illuminate PTs.
  3. Call Lender.mint() with the principal type set to Illuminate, passing the Illuminate PTs as the input.
  4. Receive newly minted Illuminate PTs, increasing the total supply without new backing.
  5. Repeat to inflate the supply further and dilute the value of all Illuminate PTs.

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.

Principal tokens (PTs) represent a claim on an underlying asset. The protocol let users swap any supported PT for an Illuminate PT, but it also accepted Illuminate PTs as the input. That meant someone could keep swapping Illuminate PTs for new Illuminate PTs, increasing the total number of tokens without adding any real assets. Since redemptions are paid out in proportion to each user's share of the total supply, everyone else's share became worth less.

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.