CoreRouter Prone to Fund Depletion or Trapping Due to Miscalculated Redemption Payouts
The CoreRouter contract calculates the amount of underlying tokens to return to a user during redemption using a potentially stale exchange rate, without verifying the actual amount received from the LToken. This can cause the CoreRouter to overpay and drain its reserves, or underpay and trap excess funds.
Source: https://github.com/sherlock-audit/2025-05-lend-audit-contest-judging/issues/464
Found by
0x15, 0xlucky, 0xzey, 1337web3, Abhan1041, BimBamBuki, Brene, CL001, Etherking, Fade, Frontrunner, HeckerTrieuTien, Hueber, JeRRy0422, Odieli, PNS, Tigerfrake, dimah7, durov, ggg_ttt_hhh, ifeco445, ivxylo, kelvinclassic11, m3dython, molaratai, newspacexyz, nodesemesta, odessos42, smbv-1923, t.aksoy, wickie, x0rc1ph3r, zxriptor
Summary
The redeem function in CoreRouter.sol (lines 82-110) is responsible for redeeming a user's LTokens for the underlying asset. The process involves:
- Fetching the current exchange rate using
LTokenInterface(_lToken).exchangeRateStored()(line 93). This rate can be stale if, for example, interest has accrued within theLTokenbut itsaccrueInterest()function hasn't been recently called to update the stored rate. - Calculating
expectedUnderlyingtokens to be returned to the user based on this potentially stale rate (line 96:uint256 expectedUnderlying = (_amount * exchangeRateBefore) / 1e18;). - Calling
LErc20Interface(_lToken).redeem(_amount)(line 98). This function call is expected to result in theLTokencontract transferring the actual amount of underlying tokens (based on its own current, possibly updated, exchange rate and any applicable fees) to theCoreRoutercontract. - Transferring the pre-calculated
expectedUnderlyingamount fromCoreRouterto themsg.sender(the user) (line 99:IERC20(_token).transfer(msg.sender, expectedUnderlying);).
The vulnerability arises because CoreRouter transfers expectedUnderlying without confirming the actualUnderlyingReceived from the LToken.redeem() call.
- If
actualUnderlyingReceived < expectedUnderlying(e.g.,exchangeRateStored()was erroneously high, or theLTokenapplies redemption fees not reflected inexchangeRateStored()),CoreRouterpays out more than it received, leading to a drain of its underlying token reserves for that market. - If
actualUnderlyingReceived > expectedUnderlying(e.g.,exchangeRateStored()was stale and low, and theLToken's internal rate was higher after interest accrual during itsredeemprocess),CoreRouterpays out less than it received, causing the excess funds to be trapped in theCoreRoutercontract.
Root Cause
The CoreRouter.redeem() function trusts the expectedUnderlying amount, calculated using LTokenInterface(_lToken).exchangeRateStored() before the LToken's redeem operation, for the final payout to the user. It does not verify or use the actual amount of underlying tokens it receives from the LErc20Interface(_lToken).redeem() call. The LToken itself may use a more current (updated) exchange rate or apply fees during its redeem execution, leading to a mismatch between expectedUnderlying and the actual tokens received by CoreRouter.
Internal Pre-conditions
- A user calls the
redeem(uint256 _amount, address payable _lToken)function. - The
_lTokenprovided is a valid LToken recognized bylendStorage. - The user has a sufficient balance of
_lToken(tracked bylendStorage.totalInvestment). - The user's redemption request passes liquidity checks (
lendStorage.getHypotheticalAccountLiquidityCollateral). CoreRouterpotentially holds some reserve of the underlying token to cover discrepancies if it overpays.
External Pre-conditions
- A discrepancy exists between the value returned by
LTokenInterface(_lToken).exchangeRateStored()(when called byCoreRouterat line 93) and the effective exchange rate or net amount thatLErc20Interface(_lToken).redeem()uses/provides when transferring underlying tokens toCoreRouter. This can occur if:exchangeRateStored()is stale (has not been updated recently viaaccrueInterest()in theLToken).- The
LToken'sredeem()function internally callsaccrueInterest(), changing the exchange rate afterCoreRouterfetchedexchangeRateStored(). - The
LToken'sredeem()function applies fees that reduce the net underlying tokens transferred toCoreRouter, and these fees are not reflected in theexchangeRateStored()value.
Attack Path
Scenario 1: Fund Drain from CoreRouter (CoreRouter overpays user)
- A situation occurs where
LTokenInterface(_lToken).exchangeRateStored()provides a rate (R_stale) that will lead to anexpectedUnderlyingcalculation higher than whatCoreRouterwill actually receive fromLToken.redeem(). This could be because:- The
LTokenapplies a redemption fee (e.g., 0.1% of the redeemed amount) which is not factored intoR_stale. R_staleis anomalously high compared to the rate theLTokenwill use internally (e.g.,R_staleis from a moment before a downward rate correction within theLToken).
- The
- A user (or an entity aware of this discrepancy) calls
CoreRouter.redeem(_amount, _lToken). CoreRoutercalculatesexpectedUnderlying = (_amount * R_stale) / 1e18.CoreRoutercallsLErc20Interface(_lToken).redeem(_amount). TheLTokencontract processes this, and due to fees or a lower internal rate, transfersactualUnderlyingReceivedtoCoreRouter, whereactualUnderlyingReceived < expectedUnderlying.CoreRoutertransfersexpectedUnderlyingto the user (line 99).CoreRouterhas now paid outexpectedUnderlying - actualUnderlyingReceivedmore of the underlying token than it received for this specific operation.- Repeated redemptions under these conditions will continuously drain
CoreRouter's reserves of that underlying token.
Scenario 2: Funds Trapped in CoreRouter (User receives less than LToken's current value)
LTokenInterface(_lToken).exchangeRateStored()provides a rate (R_stale) which is lower than theLToken's actual current exchange rate (e.g., interest has accrued in theLToken, butR_stalehasn't been updated).- A user calls
CoreRouter.redeem(_amount, _lToken). CoreRoutercalculatesexpectedUnderlying = (_amount * R_stale) / 1e18.CoreRoutercallsLErc20Interface(_lToken).redeem(_amount). TheLTokencontract processes this (potentially callingaccrueInterest()internally), uses its up-to-date higher exchange rate, and transfersactualUnderlyingReceivedtoCoreRouter, whereactualUnderlyingReceived > expectedUnderlying.CoreRoutertransfersexpectedUnderlying(the lower amount) to the user.- The difference,
actualUnderlyingReceived - expectedUnderlying, remains trapped in theCoreRoutercontract, as it's not accounted for.
Impact
- Gradual Drain of Underlying Token Reserves: If
CoreRouterconsistently receives fewer underlying tokens fromLToken.redeem()than itsexpectedUnderlyingcalculation (e.g., due to LToken redemption fees), it will transfer out more tokens than it receives. This leads to a gradual depletion ofCoreRouter's reserves for that specific underlying token. If these reserves are exhausted, further operations for that market (like other users' redemptions) could fail or be impaired, potentially damaging the protocol's solvency for that market. - Trapped Funds in CoreRouter: If
CoreRouterreceives more underlying tokens thanexpectedUnderlying(e.g., due to a stale, lowerexchangeRateStored()), the excess tokens become trapped in theCoreRoutercontract. While not a direct loss to the protocol's overall holdings, these funds are not correctly allocated (e.g., to the redeeming user who might have been entitled to more based on the LToken's actual current rate) and are not managed or recoverable by any apparent mechanism. This represents an accounting discrepancy and a loss of value for users or the protocol's distributable surplus.
PoC
No response
Mitigation
No response
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
The CoreRouter.redeem() function trusts a pre-calculated expectedUnderlying amount based on a potentially stale exchange rate, instead of using the actual amount of underlying tokens received from the LToken's redeem call.
What the attacker needed
User has LToken balance; valid LToken recognized by lendStorage; discrepancy between stored and actual rate; CoreRouter holds underlying reserves
The fix
The redeem function should use the actual amount of underlying tokens received from the LToken's redeem call for the payout, rather than a pre-calculated expected amount.
How it was found
- A user calls CoreRouter.redeem with a valid LToken and sufficient balance.
- CoreRouter fetches the exchange rate via exchangeRateStored().
- CoreRouter calculates expectedUnderlying using that rate.
- CoreRouter calls LToken.redeem, which transfers actualUnderlyingReceived to CoreRouter.
- CoreRouter transfers expectedUnderlying to the user without checking actualUnderlyingReceived.
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.
When you redeem a token, the system should give you back the correct amount of the underlying asset. Here, the system guesses the amount using an old exchange rate and doesn't check what it actually received, so it can pay out too much (losing money) or too little (locking funds).
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.