Calls To Swivel.initiate() Do Not Verify o.exit or o.vault Allowing An Attacker To Manipulate Accounting In Their Favour
The lend() function in Illuminate's Lender contract did not validate the exit and vault fields of an order before calling Swivel.initiate(), allowing a caller to choose a different internal Swivel function. This could cause more underlying tokens to be transferred from the Lender than intended, potentially stealing funds from the Lender.
Originally disclosed on Code4rena
Submitted by kirk-baird
Swivel lend() does not validate the o.exit and o.vault for each order before making the external call to Swivel. These values determine which internal functions is called in Swivel.
The intended code path is initiateZcTokenFillingVaultInitiate() which takes the underlying tokens and mints zcTokens to the Lender. If one of the other functions is called the accounting in lend(). Swivel may transfer more tokens from Lender to Swivel than paid for by the caller of lend().
The impact is that underlying tokens may be stolen from Lender.
Proof of Concept
Consider the example where initiateZcTokenFillingZcTokenExit() is called. This will transfer a - premiumFilled + fee from Lender to Swivel rather than the expected a + fee.
Recommended Mitigation Steps
In lend() restrict the values of o.exit and o.vault so only one case can be triggered in Swivel.initiate().
sourabhmarathe (Illuminate) commented:
While it is true that a user could get better execution by submitting certain orders, we don’t think this is a problem. Invalid orders would be rejected by Swivel, and users should be free to execute the best possible orders.
JTraversa (Illuminate) confirmed, but disagreed wtih severity and commented:
So reviewing this, there is an issue though it may not be high-risk.
The user can manipulate the method by sending it an order that is not the correct type to go down the intended order path.
That said, the result on line 297 is still that the calculated lent value is sent to the contract.
So the result is that the user inputting this manipulation actually still pays for their iPTs, and their underlying just sits in lender.sol until maturity with no personal benefit. The attack would none-the-less leak value and with that in mind I’d probably just drop it down to medium?
gzeoneth (judge) decreased severity to Medium and commented:
Judging as Med Risk as no fund is lost (after maturity).
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 lend() function failed to restrict the values of o.exit and o.vault, allowing unintended Swivel.initiate() code paths to be triggered.
Impact
Underlying tokens may be stolen from the Lender, though the judge noted no fund is lost after maturity.
What the attacker needed
Ability to call lend() with a crafted order
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 function that lends tokens did not check two settings on an order. An attacker could change those settings to make the contract use a different internal path, which moved more tokens from the contract than it should have. This could let the attacker take tokens that belonged to 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.