Principal types in Illuminate and Yield lending are mixed up
The lend() function in the Illuminate and Yield lending contracts mints the wrong principal token type to the user when a specific principal type is requested. An attacker could exploit this to receive a different token than intended, potentially causing downstream systems to miss expected yield or behave incorrectly.
Submitted by hyh
Lender’s Illuminate and Yield lend() mistreats the principal type p requested by a user, producing another type each time: when p == uint8(MarketPlace.Principals.Yield the Illuminate PT is minted to the user, and vice versa, when p == uint8(MarketPlace.Principals.Illuminate the Yield PT is minted to the user.
Setting the severity to be high as that’s a violation of system’s logic, that can lead to various errors on user side, and particularly in downstream systems.
For example, any additional income can be missed as a downstream system expects Yield PT to appear and tries to stake it further somewhere, while it will be in fact not available and no staking will be done. Say with if (amount/balance > 0) {...} type of logic, which is correct and common, there will be no revert in such a case. Generally such types of mistakes are hard to notice in production and a silent loss of an additional yield is quite probable here.
Proof of Concept
Currently when type is Principals.Yield the Yield PT is minted to Lender contract and Illuminate PT is minted to the user, while when type is Principals.Illuminate the Yield PT is minted to the user:
// transfer from user to illuminate
Safe.transferFrom(IERC20(u), msg.sender, address(this), a);
if (p == uint8(MarketPlace.Principals.Yield)) {
// Purchase yield PTs to lender.sol (address(this))
uint256 returned = yield(u, y, a - calculateFee(a), address(this));
// Mint and distribute equivalent illuminate PTs
IERC5095(principalToken(u, m)).mint(msg.sender, returned);
emit Lend(p, u, m, returned);
return returned;
}
else {
// Purchase illuminate PTs directly to msg.sender
uint256 returned = yield(u, y, a - calculateFee(a), msg.sender);
emit Lend(p, u, m, returned);
return returned;
}
// check the principal is illuminate or yield
if (p != uint8(MarketPlace.Principals.Illuminate) && p != uint8(MarketPlace.Principals.Yield)) {
revert Invalid('principal');
}
Recommended Mitigation Steps
When p == uint8(MarketPlace.Principals.Yield the Yield PT to be minted to the user, while when p == uint8(MarketPlace.Principals.Illuminate the Yield PT to be minted to Lender contract and Illuminate PT to be minted to the user, i.e. the logic should be switched.
For example:
// transfer from user to illuminate
Safe.transferFrom(IERC20(u), msg.sender, address(this), a);
- if (p == uint8(MarketPlace.Principals.Yield)) {
+ if (p == uint8(MarketPlace.Principals.Illuminate)) {
// Purchase yield PTs to lender.sol (address(this))
uint256 returned = yield(u, y, a - calculateFee(a), address(this));
// Mint and distribute equivalent illuminate PTs
IERC5095(principalToken(u, m)).mint(msg.sender, returned);
emit Lend(p, u, m, returned);
return returned;
}
else {
// Purchase illuminate PTs directly to msg.sender
uint256 returned = yield(u, y, a - calculateFee(a), msg.sender);
emit Lend(p, u, m, returned);
return returned;
}
sourabhmarathe (Illuminate) disputed and commented:
This suggested mitigation is not accurate. Although there is a problem with Illuminate’s
lendmethod, the suggested mitigation does not resolve the problem. Furthermore, the suggested mitigation would result in Yield’slendnot minting tokens to the user. We will leave it up to the judges to decide what to do with this issue.
Given it is not very clear what
pmeans in this function / what this function is doing and is not exploitable for profit, this seems to be an input validation / comment issue which is out-of-scope in this context. I will judge this as Low / QA because of the unclear comment.
Well, p is a type of principal and I see little ambiquity in this. Furthermore, the issue is of logic type, not comments and quite far from input validation. @gzeoneth could you please comment on the decision? That’s logic violation/incompleteness, which isn’t QA.
gzeoneth (judge) decreased severity to Medium and commented:
Reviewed and adjusting to Med Risk.
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 a logic error in the conditional check that compares the requested principal type against the wrong constant, causing the branches to be swapped.
Impact
This could lead to various errors on the user side and in downstream systems, such as missed additional income, but the judge noted it is not exploitable for profit.
What the attacker needed
User calls lend() with a principal type
The fix
The logic should be switched so that when the requested type is Yield, the Yield PT is minted to the user, and when it is Illuminate, the Yield PT is minted to the Lender contract and Illuminate PT to the user.
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.
In a lending system, users can choose between two types of tokens that represent their investment. This code mistakenly gives them the opposite type of token from what they asked for. That means someone might get a token they didn't want, and any system that relies on the correct token could fail to work as expected.
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.