Skip to content
Business logic Audit finding Intermediate

withdraw eToken before withdrawFee of eToken could render withdrawFee of eToken unfunctioning

The withdrawFee function requires the contract's eToken balance to cover accumulated fees, but if the admin first withdraws all eTokens, the balance becomes zero while fees remain, making withdrawFee unusable. An attacker cannot directly exploit this, but the admin must rely on a slow withdrawal process to recover future fees.

Kumpa Follow

Originally disclosed on Code4rena

Submitted by Kumpa

https://github.com/code-423n4/2022-06-illuminate/blob/912be2a90ded4a557f121fe565d12ec48d0c4684/lender/Lender.sol#L705-L720

https://github.com/code-423n4/2022-06-illuminate/blob/912be2a90ded4a557f121fe565d12ec48d0c4684/lender/Lender.sol#L659-L675

Vulnerability Details

withdrawFee of eToken requires the amount of eToken in Lender.sol >= fees[eToken] so Safe.transfer will not revert. However if the admin withdraw(eToken) first, the balance of eToken in Lender.sol will equal to zero while fees[eToken] remains the same and withdrawFee(eToken) will become unfunctioning since eToken in the contract does not match fees[eToken]. The admin will need to rely on withdraw, which takes 3 days before transfering, to get the future fees of eToken.

Recommended Mitigation Steps

Add fees[eToken] = 0; after withdrawals[e] = 0; in withdraw.

sourabhmarathe (Illuminate) confirmed and commented:

Appears to be similar to #115 but not exactly the same.

JTraversa (Illuminate) commented:

Yeah I’d say definitely a separate ticket / reasonable recommended remediation.

Turns out this one should’ve been disputed (the only case where the emergency withdraw is called is when we are migrating contracts due to an emergency, meaning the old state actually doesnt matter at all).

JTraversa (Illuminate) commented:

As a quick comment in our final review, the inability to use methods on an aborted contract would only matter should you want to reinitialize the same contracts.

Given we would only abort our contracts due to vulnerabilities, there would never be such a scenario.


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

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 withdraw function does not reset the fees mapping when it transfers out all eTokens, so the recorded fees remain but the balance is zero.

Impact

The withdrawFee function becomes unusable, forcing the admin to use a slower withdrawal method that takes three days to recover future fees.

What the attacker needed

Admin calls withdraw(eToken) first

The fix

The withdraw function should reset the fees mapping for the token after clearing the withdrawal record.

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.

This is a smart contract issue where a function that pays out fees stops working if the contract's token balance is emptied first. The admin can accidentally break the fee withdrawal by taking out all tokens, leaving no tokens to cover the recorded fees.

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 Kumpa

View all

3 more disclosed reports, best first.

More from Illuminate contest

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.